Iron Speed Technical Forums
Sign up Latest Topics

  Author   Comment  

Posts: 145
Reply with quote  #1 

I have a Job Table. When I create a new job
I want to create a One WorkOrder Master record
and multiple WorkOrder Child records (many field values auto populated with
default values )

I am able to create the Workorder master from the Save button click of 
Job table, because I can get the new JobID.

After that How do I get the ID of newly created work order master ?

Please advise.



Avatar / Picture

MVP Consultant
Posts: 1,686
Reply with quote  #2 
If you are doing this with straight Iron Speed, it will do it for you.  Otherwise consider the CommitTransaction Event where you can retrieve the new PK after the parent record has been saved, and then assign it to child records yourself.


Miles Gibson, MScIS
Iron Speed MVP
Senior Consultant, Principal
Milestone Software Inc.\localizer 
Milestone Localizer: Full Localization for your Iron Speed applications!

Avatar / Picture

MVP Developer
Posts: 1,962
Reply with quote  #3 
You may override the CommitTransaction object Retrieve the newly save data as follows:

public override void CommitTransaction(object sender)
                // Get the record control.
                {TableName}Record rec= this.{TableName}RecordControl.GetRecord();
                // Retrieve the primary key and do more code customization like passing the retrieved value to another page, stored procedure and so on.
                String tempId = rec.{TableIDName}.ToString();
                // Write your custom code below.

Note: TableName And TableIDName must be replaced with actual names.

Jimi J


  Jaime Jegonia

Iron Speed MVP Developer

". . . and whoever sows generously will also reap generously" 2 Cor 9:6


Posts: 145
Reply with quote  #4 
Let me explain the problem again.
Job Table - WorkOrderMaster Table - WorkOrderDetails Table
This is a parent - child - grandchild table setup.

When user adds a new job, I want to automatically insert 
- one workorder master record
- three default work order details records

I can get the new job id like this:

Dim rec As JobRecord = Me.JobRecordControl.GetRecord
Dim tempId As String = rec.JobId.ToString()

And I can insert a WorkOrder Master record like this:

Dim wmec as New workordermasterRecord
wmrec.jobid = CInt(tempid)
wmrec.wmdate = today()

Now this will insert a new work order master record. 
I want to get the id of this new work order master record.

After that, I want to insert three record in work order details table.

Finally commit the transaction.

Please note that I dont have a work order master control inside the
Add Job page.

How do I get the newly inserted work order master record?

Or, Can I add a work order master record control in Job page and thro
that can I get the new record id?

Pl advise.



Avatar / Picture

MVP Consultant
Posts: 968
Reply with quote  #5 

I'd write an Insert trigger on the jobs table and do it all at the database level.

That being said, I believe that the wmrec key will be updated after the save() so you can retrieve the newly created key from there and insert it into the workorderdetails records.

C. Bryan Patrick II
Iron Speed Designer MVP Consultant
Pseudo Consulting
Previous Topic | Next Topic

Quick Navigation:

Easily create a Forum Website with Website Toolbox.

Download Iron Speed Designer

Terms of Service Privacy Statement