Iron Speed Technical Forums
Register Latest Topics
 
 
 


Reply
  Author   Comment  
krishna

Registered:
Posts: 141
Reply with quote  #1 
Hi

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.

thanks
Krishna



miles

Avatar / Picture

MVP Consultant
Registered:
Posts: 1,679
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.

HTH,

__________________
Miles Gibson, MScIS
Iron Speed MVP
Senior Consultant, Principal
Milestone Software Inc.

http://www.ironspeedmvp.com\localizer 
Email: miles@milestone.ca
Milestone Localizer: Full Localization for your Iron Speed applications!
JimiJ

Avatar / Picture

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

public override void CommitTransaction(object sender)
            {
                 base.CommitTransaction(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.

Cheers,
Jimi J

__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

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

krishna

Registered:
Posts: 141
Reply with quote  #4 
OK
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()
wmrec.save()

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.

regards
Krishna



pinbot

Avatar / Picture

MVP Consultant
Registered:
Posts: 963
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
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.

Download Iron Speed Designer

Terms of Service Privacy Statement