but when End Loop was reached a occurred
I suggest posting at least the loop portion of your script.
To post a script to the forum:
- You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
- You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
- If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
- If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
Screen Shot attached!
Were also going to need to see the script 'Update Inventory'. I suspect it's not coming back to the first layout, at the correct record.
That would be my guess. If so, you can add:
Go to Layout [orginal layout]
Immediately after the perform script step near the end of your loop.
@Phil..question. In his posted script, the last 2 set field steps. They appear to be from 2 different TO's. Would (or could) that cause a layout change if fields come from 2 different TO's....just wondering. Thanks
Second Script attached!
Follow Phil's advice, you need to change back to original layout. Also, you're new record request is commented out, so it won't create a new record
Another question, and just my curiosity, why are you setting globals, based on fields, then setting fields based on globals? Wouldn't the standard Set Variable, Set Field be a better way to go? I know there are situations where globals are used to give the user the option of canceling a new record creation without having to do a Revert, or some other work around.
@Steve, I know of no
way for Set Field to cause a layout change. Set field interacts with the field at the data level, not the layout level so it can't even trip a script trigger such as OnObjectModify.
My experience level isn't there yet, I'm still on the up side FM scripting curve. I know what to do from my scripting experience with MS Access 2010/VBA/SQL but my problem is quickly finding how to do it in FM. It doesn't help when the project has a tight delivery date.
The manor in which I use the Global fields was taken from a solution I created years ago with FM v3.1.
Please don't laugh, I'm under the gun.
Global fields were a standard way to do this before we had variables. They work just fine for this purpose in today's versions, but you might want to check out variables as a slightly simpler alternative with today's versions.
Regarding the commented out new record request, it is there for testing, I wasn't sure if I needed it or not.
Adding Go to Layout [orginal layout] Immediately after the perform script step near the end of your loop didn't work, I still have the infinite. I also noticed with Script Debugger that when "Update Inventory" script runs, I see each field in the layout is populated with the Global field data but no new record is created.
Looks like you need to add the new record request, and maybe a commit records. Are you actually changing layouts? If not you may be adding (when you put the new record request back in) a new record to the end of the found set and will never get to the end. Show the tool bar and watch your found set of records, see if they increase.
See if this helps.....Make a backup first.
When you perform your subscript, open a new window, go to correct layout, create new record, set fields, commit record, close window. Take out the Go to Layout (original layout) this time on the original script and see if that helps
Yes, the "Update Inventory" script does go to a new layout "Inventory_List". At this point in the main script, "Update Inventory" is only used to set field values in the inventory table while creating a new record.
The commented out New Record request step in "Update Inventory" script is a question you asked about earlier and I said I didn't know if I needed it or not.
I've removed the comments text from New Record request, added Commit Record script step and now the "Update Inventory" script is working, it now creates a required new record.
The issue now is the return from "Update Inventory" script. The earlier posted suggestion was to add "Go to Layout [original layout]", this step has been added and script action does return to the original layout but it does not return to the original record. If the script step is part of a loop, incorrect information in now being used.
I guess my question is must I use set field with one of the Global fields to insure the return to the correct record?