Entrance Function
![Scripting studio showing an example of form script and the entrance function.](img/UserScripting/EntranceFunction.png)
An Entrance function serves as the starting point in your script. For more on functions see Functions.
The Entrance function is associated with a form event in the Scripting Studio Tools and Settings options, see Events.
The Entrance function field value is the name of the function without parenthesis (or parameter, if used).
Entrance Function Type Parameter
The entrance function can optionally take a type parameter which will be passed one of:
-
‘new’ — this is passed when saving a new form.
Note:This applies to New and New, from another actions.
-
‘edit’ — this is passed when updating an existing form.
Note:This also applies when creating a clone.
-
‘approve_request’ — this is passed when a record is submitted for approval.
-
‘approve’ — this is passed when a record is approved.
-
‘reject’ — this is passed when a record is rejected.
-
‘unapprove’ — this is passed when a record is unapproved, and is supported by bookings, booking requests, expense reports, invoices, purchase orders, purchase requests, schedule requests, and timesheets.
Note:To enable the Unapprove type, contact OpenAir Customer Support and ask them to enable the “Enable user scripts to use an unapproval context in the after approval event” switch.
The type value will be the same regardless of the form Event. For example, if you call your entrance function on “After save” when creating a new form you will still be passed a type value of ‘new’.