Set Session Identifier for PSoS Progress

I've been running a lot of Perform Script on Server scripts ( PSoS ) and have been frustrated not being able to see its progress.

So I googled a bit and learned that Set Session Identifier can be used to show progress in FileMaker Server Admin Console. As a bonus, if you prefix the ID with a space, it'll jump to the top.

Just thought this might be useful to others! Here's the calc I'm using when setting the Set Session Identifier...

Let ( [

theLoopTimeSpent = Get ( CurrentTimestamp ) - $LogScriptBeginTS + .00001 ;
theCountToGo = Get ( FoundCount ) - Get ( RecordNumber );
theCountToGo = If ( theCountToGo = 0 ; 1 ; theCountToGo );
theSecondsToGo = theLoopTimeSpent / Get ( RecordNumber ) * theCountToGo ;

theToGoMessage = Case (
theSecondsToGo < 60 ; Round ( theSecondsToGo ; 0 ) & " Sec" ;
theSecondsToGo < 60 * 60 ; Round ( theSecondsToGo / 60 ; 1 ) & " Min" ;
Round ( theSecondsToGo / ( 60 * 60 ) ; 1 ) & " Hr"
) ;

theToGoMessage = theToGoMessage & " " & Round ( 100 * Get ( RecordNumber ) / Get ( FoundCount ) ; 2 ) & "%"

] ;

" PSoS " & theToGoMessage & ": " & Get ( ScriptName ) & " " & Get ( AccountName )

)

9 Likes

Thanks @HalGumbert . I remember hearing devs mention this when the session identifier feature was first released, but I never pursued this. I appreciate you mentioning it.

2 Likes

Fantastic! Thanks for sharing @HalGumbert !

2 Likes

If you create new records or modify then SessionID will show up in RECORD CREATION NAME and MODIFICATION NAME. So that would be a trade-off...

4 Likes

Cool idea.

I usually use our Log function in MBS FileMaker Plugin to write a line to our log files on server. See Logs folder for recently changed .log files.

1 Like

@FileKraft You could always temporarily set the ID back to its default value during those operations. :wink:

1 Like

@HalGumbert really great tip Hal! Damn, now I’ve got to go refactor all time consuming scheduled scripts on production…

1 Like

Yes and hope or pray the admin console will update quick enough on changing…

It's pretty quick, I think. While looping I tend to pause for 10 seconds after every 500 recs processed and I can see my "10s Pause" message flip on and off. Not immediate, but good enough!

1 Like

@HalGumbert Thank you for the amazing technique which I am already using for some server side scripting where progress feedback is desired.

Just as I experienced it so far on one server is that when looping through 200 records it updates the progress display only 3 times and I don't want to pause it to slow it down just for the sake of catching up with the display.

Since the admin console live log feature disappeared with FMS17 when brought back later as interactive log in FMS19 it won't update the selected log items (at least not on our install base).

Maybe our server is lazy to update timely ... Thanks again!

1 Like