Create Child Record Using Set Field

According to an old Community post from philmodjunk, “A set field script step performed from this layout, that assigns data to a field in the related table will also create a related child record if no such child record exists…”

My POS interface file includes a SALEDB table (from the data file) and a related INTERFACESALEDB table. Based on the SALEDB context, a “set field” script step appears to be creating a child record in INTERFACESALEDB. This seems to work fine when run on the client.

However, when I run this script using PSOS, the script appears to fail at that point. I’ll double-check the context on the server, but I believe it’s the same as the local session.

Is there something else that would cause the “set field” step to fail?

Are you going to the right layout and locating the right record?

2 Likes

That may be the issue. What confused me is that some of the steps execute just fine. Only the steps involving the child layout seem to be problematic.

When you perform PSOS the db opens on record one of the default layout. Your script parameters have to pass all the information you need to establish context and the correct found set.

The script is passing parameters and I believe the layout is correct. I may try adding a “go to layout” step and explicitly creating a new record.

When I say default layout I mean the layout that opens when the database opens. Chances of it being the layout that you want to use is most likely zero. The PSOS script has to go to the layout you want. It has to find the correct record. Then it can proceed.

1 Like

@Malcolm — I’ve verified the layout and context are correct. However, after further debugging, I believe the script may be failing due to record locking. (“Get Last Error” returns error 301.) At this point, I’ll have to research how to deal with having the client and server both try to update the same record. Record locking is an area I’ve not yet had to traverse. Thanks for you assistance.

Ah. Well you could start by committing the record on the client before you call PSOS.

Also, give the user feedback so they don’t reopen the record.

2 Likes

That solved the problem, thanks.

1 Like