Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6942 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted (edited)

Hello, I'm tryig to write a script that reads thu 1 layout (table) and for each record it finds it inserts a record into another layout (table). The tables aren't identical.

It is to populate an invoice line-item table prior to the invoice being displayed.

The problem I'm getting is that when I switch layouts to insert the record I lose position in my original source layout, and the loop just carries on forever!

I've searched through a few FM forums & web pages & can't see an obvious answer (usiing FM Pro 8 Advanced). I'm very new to FM so apologies if this is an obvious answer.

Grateful for any help anyone can give. It's driving me nuts!

Edited by Guest
Posted

Create a second script for the creation of the record in the line items table. In that script do this:

go to layout(the layout for this table)

new record

do what you need done

go to layout(original)

That's it. Perform this script inside the loop of the main layout being processed and you should have no problem.

Alternatively, if the table were related, a simple Set Field from inside the loop would automatically create the record in the second file (if there was not already a related record, and the relationship is set to allow record creation). I like this method since if makes programming easier.

Echo

  • Newbies
Posted

Echo,

Thanks very much for the quick response. I'll try it out tonight.

Just to help my understanding - does this mean the record position in a script is local to that script instance? So by starting another script and going to a different layout in that sub-script this doesn't interfere with the current layout record position?

Posted

While I cannot give you a definitive answer on that question, in my experience that appears to be the case. Previous to FM7 we would do the same thing, except that the second script would reside in a different table/file and so definitely a different record pointer/environment etc.

Since we can do all of this now within a single file and script in FM7 and later, it still makes sense to me that we need to split the function into two scripts as I am not sure where the record pointer ends up pointing if we do it in one script. Others can probably shed more light on this issue.

Echo

  • Newbies
Posted

Echo, just to confirm that worked fine.

I used global variables to pass the data down to the called sub-script which did the insert, and when returned I had the same record position as before.

Thanks for your help,

Chris.

This topic is 6942 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.