1 Reply Latest reply on May 18, 2017 9:05 AM by mikebeargie

    Check if a Script is running FM14



      i have loaded a script by url http://my_url?script=my_script


      works fine, but have a way to check if this script is running ?

      or check if no one script running then do something...


      i take a look on documentation but not like this.

        • 1. Re: Check if a Script is running FM14

          For you to log individual script executions, you need to setup the structure and functions yourself. Script executions are unique to the user session, so you can't query what scripts other users are running. You need to log that information yourself.


          So create a new table "ScriptLog", with fields for "PrimaryKey", "StartTimestamp", "EndTimestamp", "Script", "User". You can autofill the StartTimestamp and User using Get(CurrentTimestamp) and Get(AccountName)


          Then at the beginning of your MyScript add:

          Go To Layout ( "ScriptLog" )

          New Record

          Set Field [ ScriptLog::Script ; "MyScript" ]

          Commit Record [ no dialog ]

          Set Variable [ $$logID ; ScriptLog::PrimaryKey ]

          Go To Layout [ original layout ]


          At the end of your MyScript, "close" the log:

          Enter Find Mode [ no pause ]

          Go To Layout ( "ScriptLog" )

          Set Field [ ScriptLog::PrimaryKey ; "==" & $$logID ]

          Perform Find

          Set Field [ ScriptLog::EndTimestamp ; Get(CurrentTimeStamp) ]


          Now that you are logging the start and end times of each time the script is run, you can check and see if any scripts are currently being run like this:

          Enter Find Mode [ no pause ]

          Go To Layout ( "ScriptLog" )

          Set Field [ ScriptLog::Script ; "==MyScript" ]

          Set Field [ ScriptLog::EndTimestamp ; "=" ]

          Set Field [ ScriptLog::StartTimestamp ; "=<" & Get(CurrentTimeStamp) ]

          Perform Find

          If [ Get(FoundCount) > 0 ]




          End If

          Go To Layout [ original layout ]

          Enter your own actions in the If/Else statement there and you're good to go.

          1 of 1 people found this helpful