davehob

Creating records with Set Field

Discussion created by davehob on Dec 14, 2012
Latest reply on Dec 20, 2012 by StephenWonfor

A while ago, I picked up the technique of creating related records using a global field in the parent table, set to “”, and related (in a “create” relationship) to a field in the child table which would never be equal. Hence the creation is forced when setting any other field in the child record. So far so good. Like this, in a situation where the parent record is a Session (SSN) with one or more related Room Booking (RBK) records:

 

Set Field [SSN::SSN_g_RBKCreate; “”]
Set Field [SSN to RBK for creation::RBK__kf_RSC_ID; $CurrentRoomID]

 

But then I needed to set a further field in the newly created child record. Simple, I thought, just do a further Set Field, via the same “create” relationship, like this:

 

Set Field [SSN::SSN_g_RBKCreate; “”]
Set Field [SSN to RBK for creation::RBK__kf_RSC_ID; $CurrentRoomID]
Set Field [SSN to RBK for creation::RBK_RoomSetup; $RoomSetup]

But I now see that the second Set Field via the create relationship just creates a second record, which is definitely NOT what I want, although I understand why it's doing it.

 

So what I’m now doing is using a second global field in the parent table, and relating that to the relevant field in the child table. Then, setting the one field through the create relationship has the effect of creating the record, and setting other fields involved in the relationship. So the script is now like this:

 

Set Field [SSN::SSN_g_RBKCreate; “”]
Set Field [SSN::SSN_g_RoomSetup; $RoomSetup]
Set Field [SSN to RBK for creation::RBK__kf_RSC_ID; $CurrentRoomID]

 

It seems to work fine, but is this the best way to achieve what I want? I’d really appreciate any feedback.

 

Regards,

 

Dave.

Outcomes