AnsweredAssumed Answered

Perform Script on Server w/OnFirstWindowOpen

Question asked by dewitte on Jan 29, 2019
Latest reply on Jan 30, 2019 by BruceHerbach

Hello!  I recently started using the Perform Script on Server command.  I haven't needed it before or didn't think I did. 


I'm curious about a best practice


I develop webdirect apps and I always have a "OnFirstWindowOpen" script.  This script usually handles setting up variables based on the current user.  The app uses domain groups to log in so the user is authenticated as they come in.  However, on most of my apps, I maintain a list of users that can be managed by an admin of that particular app.  So, in this OnFirstWindowOpen script, I might set a variable such as "$$IsAdmin, or $$ValidUser", etc - based on this user table.


What I just found out is that if I do a Perform Script on Server, the server actually logs in and hits this script.  It took me a little debugging to figure that out since I didn't expect it.  I thought it would just run the command I provided.


I therefore added the following statements to the top of the OFWO script -

If LeftWords ( Get (ApplicationVersion) ; 1 ) = "Server" and Get(SystemPlatform)<>4

Exit Script

End If


I also had to tell my app in the security to all fmapp logins.  I didn't have that checked before.  In the OFWO script, I already tell the user they have to be in WebDirect, so I didn't have an issue, however the server wouldn't log in.


This all works great, however it really makes me wonder if I shouldn't be using an OnFirstWindowOpen script in the first place.  Have I been using a wrong approach all along OR is it normal to add a server login check to scripts in apps that might use Perform Script on Server?


What is a best practice for this?