Retrieving the new primary key after executing .NewRow and .Save


Author
Message
Jeff Pagley
Jeff Pagley
StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
I could not find the answer on the forum or in the SF Help.  How do I retrieve the newly created primary key after executing the following code:

  Using job As New PRJTJobsBO
   With job
    .NewRow()
    .job_Customer = "jeff"
    .job_Name = "Jeff's Job"
    If .Save = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then
     Return ...newly created primary key??????
    End If
   End With
  End Using


Thanks,

Jeff

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Assuming that the PK is auto incremented, you just access its property:



Using job As New PRJTJobsBO

  With job

    .NewRow()

    .job_Customer = "jeff"

    .job_Name = "Jeff's Job"

    If .Save = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

      Return .job_ID '-- if job_ID is the BO property that contains the ID

    End If

  End With

End Using

Jeff Pagley
Jeff Pagley
StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)StrataFrame User (467 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
That was it.  I thought about that, but for some reason I was thinking when the BO added a record it reset the cursor to the first record in the BO and I needed to do something special to retrieve the new ID.

Thank You,

Jeff

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Things are often as easy as they seem with SF. When I don't know how to do something, I'll often just try what might work and it often does. Glad that helped.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Thanks, Greg! Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search