Writing PreScript and PostScript
click image to shrink and magnify.
You can enter the client side JavaScript you want to execute before or after raising this event on the client side. You can use PaperSave Profile Fields using the \"profile\" object followed by a \".\" and the field name (use \"_\" for spaces if profile field has spaces).
Example: profile.Invoice_Amount (for a profile field called \"Invoice Amount\"). Remember that all object names are case sensitive. You can test the script by providing test values in the Profile Input section on the left and then by clicking on the Test Script button. Output profile values will be displayed in the Profile Output section on the right. You can view the output XML by clicking on the View Output button. Click here to get the list of PaperSave Variables that can be used while executing script.
Defining a Pre/Post Script on Workflow Events Approve/Reject/Association or any other custom event.
Defining a Pre/PostScript allows you to determine what should get fired before and after the event is auto raised from the client side. The Pre Event can modify the values of the profile fields, which will be updated in the database. But a PostScript cannot modify the values of the profile fields. If an attempt is made to modify the values PaperSave will show an error message.
Note: |
||||||||||
Global Variables declared for Pre/Post Scripts cannot be used for below mentioned activities:
|
You are able to prevent the raising of the PreScript event by pressing return cancel. If multiple rows are selected and some of them come up as "cancel=true," PaperSave will show a message indicating which events can and cannot be raised.
Note: |
||||
|
Generating Custom Error Message from Script Editor window using Java Script:
PaperSave gives you the ability to generate custom error message by writing a script in script editor window in below given format:
Note: |
With PaperSave 5.2.1, you will experience a more easy and convenient way of writing scripts in script editor window for various classes like Profile, Parameter, Globals etc. So this will ultimately reduce the human error caused during writing the scripts. Click here to know more about Javascript Intellisense. |
throw new Error("<message text>")
You can write the script as given in below example:
try{
if(<condition if true>)
throw new Error(<"My Exception Message">);
}
catch(e)
{
throw (e.message);
}
Post Script can be used to execute some java script on Post execution of the event on which it is written. However, you can not use PaperSave.Cancel Script function in a Post Script Activity. You can view the below displayed screen.
In PaperSave Settings:
As mentioned earlier in this section, Pre/PostScripts are pieces of code that are executed before/after any action is performed like Approve, Reject, Associate, or any other. For more examples, click PaperSave JavaScript library functions.