AnsweredAssumed Answered

Problem Script: Generating Unwanted New Records from Loop

Question asked by dale_allyn on Jul 9, 2017
Latest reply on Jul 9, 2017 by dale_allyn

FileMaker 16 Server

 

I have not been able to replicate this issue on local FMPA instance, but it comes up on the served version.

 

This is a "Report Submission" form for a laboratory which takes-in submissions from clients. Each submission has submission line items (one submission, one or many line items). On the submission layout is a portal for inputting the submission line items. The portal is where the problem occurs.

 

On Submit (submit, not just commit to save) some basic checks for empty fields are done, then a loop to do some things, with a counter. The counter is used rather than "exit after last" because records can be created via the portal, so there is always one more blank record opportunity in the portal.

 

I'm testing against "0" for the variable countdown, but wonder if my syntax can be improved, because at some (seemingly) random times, 0 (zero), is not being respected by the loop steps. Will using "<1" be more stable? What else am I missing? The starting variable is set via a summary field, but locally has no issues.

 

Here's the loop section of the script:

 

Set Variable [ $itemCount; Value:Sub_Line_Items::s_ItemsCount ]

Go to Portal Row

[ First ]

Loop

#Clear unnecessary fields by item type.

If [ Sub_Line_Items::ItemType "Pearl-like: Strung" ] Clear [ Sub_Line_Items::prl_strung_detail ]

[ Select ]

Clear [ Sub_Line_Items::prl_strung_rows ] [ Select ]

End If
If
[ Sub_Line_Items::resubmission = 1 and IsEmpty ( Sub_Line_Items::resubPrevReportID ) ]

Show Custom Dialog [ Title: "Previous Report ID Missing"; Message: "You have marked an item as a Re-submissioin, but the Previous Report ID is missing. "; Default Button: “OK”, Commit: “No”; Button 2: “Add Later”, Commit: “No” ]

If [ Get (LastMessageChoice) = 1 ]
Go to Field [ Sub_Line_Items::resubPrevReportID ] Exit Script [ ]

End If End If

If [ IsEmpty ( Sub_Line_Items::reportNumber_ID ) or IsEmpty ( Sub_Line_Items::barcode ) ] Perform Script [ “Commit Submission Item” ]

End If

Set Variable [ $itemCount; Value:$itemCount - 1 ]

Exit Loop If [ $itemCount = 0 ]

Go to Portal Row

[ Next ]

End Loop

 

Stepping through is locally it performs as needed, but in production on the server we're getting runaway record creation.


Thank you for any input.

 

Outcomes