AnsweredAssumed Answered

How can I stop portal records being sorted while a script is running?

Question asked by macaque on May 2, 2016
Latest reply on May 2, 2016 by macaque

I have a problem with portal records sorting while my script is running such that results get entered into the wrong record. I thought recent versions of File Maker (I'm using 14) prevented sorting while scripts are running.

 

I have a layout with several tabs and one of these contains a portal of records intended to manage staff holidays on a rota. The user enters a start and end date for the leave period and ticks a checkbox. This triggers a script that applies the date range to the rota and returns with the number of work shifts affected.

 

During my testing I entered dates for March and April and then added one for January. The script toddled off to do its bit but on returning to the original layout and tab, the January dates had sorted themselves to the first portal row and so the script result overwrote April's entry. The only way I can stop this is to remove the portal's sort paramter (by leave start date) but I'd like to keep that 'cos it looks nice.

 

My script saves the active portal row to a variable $APR before going to the Rota layout. Here are the steps on its return:

 

...

Go to Layout [ original layout ]

Go to Object [ Object Name: "LeaveTab" ]

Go to Portal Row [ No dialog ; $APR ]

Set Field [ Leave::ShiftsAffected ; $ShiftCount ]

Exit Script [ ]

 

By inserting pauses in various parts of my script I can see that the sort occurs just after Go to Object. I've tried adding an Unsort Records command just after this point but it doesn't help. Any ideas?

Outcomes