Can you spell out what you are doing in more detail. Maybe by posting your script as well as spelling out your relationships involved?
The details in that script could be crucial.
On a second note, not sure why you need a script to 'search for line items'...
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 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.
- 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. (Use the HTML option on the database tab panel and click "Source" in the Post A Answer tool bar to paste the text into the forum's HTML editor.)
My only issue is the Equipment List Record is not created until the name is committed. but my users type the name and click the button that activates this script without commiting the name/creating an equiqment list record.
My script is as follows
Set Variable [ $EVENTID; Value:EVENT::Event ID ] Set Variable [ $EQLID; Value:Equipment List::eq list id ] Go to Layout [ “Quote Input” (Line Items) ]
Set Error Capture [ On ]
Perform Find [ Specified Find Requests: Find Records; Criteria: Line Items::Event ID: “=$EVENTID” AND Line Items::EQ list ID: “= $EQLID” ]
[ Restore ]
If [ Get ( FoundCount )=0 ]
Set Field [ Line Items::Event ID; $EVENTID ] Set Field [ Line Items::EQ list ID; $EQLID ]
Perform Find [ Specified Find Requests: Find Records; Criteria: Line Items::Event ID: “=$EVENTID” Omit Records; Criteria: Equipment List::EQ list status: “="Declined"” ]
[ Restore ]
Perform Script [ “Sort Line Items” ] Adjust Window
[ Resize to Fit ]
Apologies, but this doesn't fully answer my request for more detail.
What relationships do you have in place?
Your script references three different tales: Event, EquipmentList and LineItems.
How are they linked in relationshps?
And on which of these is your layout based? Events?
This all looks a bit puzzling because the go to layout script step should, I think, cause the records to be committed, but just from what i see here, If I were to insert a commit records step, I'd add it immediately after the second Set Variable step so that you capture the information from the active portal row before committing records and losing the focus on a specific portal row.
Sorry for the confusion. The image i posted is of a portal on the event table and layout. a new equipment list is created by naming one in the portal shown above.
My Relationships are :
Events have many equipment lists
Equipment list have many line items.
Line Items have one inventory reference that must have event ID and EQLIST ID fields filled out to be displayed in my Quote Input layout(referencing line items table)
The problem I am having is that if a user does not click outside the new equipment list name field, the equipment list ID variable cannot be set becaue it is not created until the name is commited. placing a commit in this script does not seem to work because the portal row cannot be active until its unique ID has been created.
So you have this? (subsitute your field names for mine)
Events::__pkEventID = EquipmentLists::_fkEventID
EquipmentLIsts::__pkEquipmentLIstID = LIneItems::_fkEquipmentListID
The problem I am having is that if a user does not click outside the new equipment list name field, the equipment list ID variable cannot be set becaue it is not created until the name is commited
Do you mean the the FIELD EquipmentLIsts::__pkEquipmentLIstID is not set to auto-enter a serial number value until the EquipmentLists record is committed?
If so, why not select the "on created" option for this auto-enter setting?
If not, please continue to fill in the missing details.
The field is set to auto-enter serial number on creation but in this portal, it does not create until a name is filled in. If i name it and then click outside the name field, a serial number is generated. But if I trigger the script while the name field is still active, it will not capture the eq list ID because it generates after the varible is captured.
Which serial number are we talking about?
Set Variable[ $EVENTID; Value:EVENT::Event ID ]
Set Variable[ $EQLID; Value:Equipment List::eq list id ]
Red or blue?
Red. it commits. just after the script has ran. when i go back through it. it works
The change in layout immediately after this step commits the record.
Try this code at the beginning of your script:
Set Variable [$Row ; Value: Get ( ActivePortalRowNumber ) ]
Go to Object ["object name of this portal goes here"]
Go to Portal Row [ No dialog ; $Row ]
You'll need to use the Name box in the inspector's position tab to give the portal an object name to use with the go to object step. Go to Object makes sure that the correct portal has the focus so that go to portal row is applied to the correct portal.
If you have a single portal on your layout, this step is not striclty necessary, but makes for a safer script as your script will continue to work correctly even if you add another portal to the layout at a later date.
That's odd. The new record should be created as soon as you begin typing the name. It sounds like you have the auto-enter serial number set to On Commit. You have said it's set to On Creation though. Odd.