Navigation:  User Guide for PaperSave for Blackbaud's Student Information System > PaperSave Configuration > PaperSave Settings > Workflows > Workflow 1.0 >

Writing PreScript and PostScript on the Workflow Event

Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

Writing PreScript and PostScript

 

pre_script.zoom70

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:

 

CustomSetStateActivity
MoveToQueueActivity
WorkflowHistoryStampActivity
SendEmailActivity
AssociateDocumentActivity

 

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.

 

pre_script03

 

Note:

When PaperSave.ShowMessage function is used while writing Scripts in Script Editor window and as you click on Test Script button, below displayed warning message will open. This message says that PaperSave does not allow showing messages with server side scripts if PaperSave.ShowMessage function is used in ScriptActivity and as a result your script may not run properly.

 

Show Message error-2

 

Moreover, if PaperSave.ShowMessage function is used in ScriptActivity then while the Workflow is compiled or published, below displayed warning message will open. This message warns you that you have used PaperSave.ShowMessage or Windows.alert functions within the ScriptActivity of Workflow. PaperSave does not allow showing messages or alerts within server side scripts. As a result your script may not run properly. Clicking on OK button will compile the workflow normally.

 

Show message error-1

 

 

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:

 

pre_script02

 

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.