Skip to main content

ScriptLink Error Codes

Along with field values and attributes, ScriptLink allows you to send back an error code and an error message to a form.

Error codes can be used to display pop-up messages, stop the action that triggered the script from being completed (either conditionally or unconditionally), open an external web page, or open another form.

Available error codes

Code Value Result Notes
0 Default No message shown.

 

1 Hard stop A message box is displayed with the text of your choice, and whatever action triggered the script is reverted. Stopping an action:

If you want to prevent an action that triggers a script from being completed, you can do so with error code 1. If you use this error code, a message will be displayed, and whatever action that was taken that triggered the script will be reverted. On a form field, changing a selection or editing or entering a value can trigger a script.  If that script returns error code 1, whatever value or values were present in the field that triggered the script before it was changed will be restored.

On the form load and prefile form-level events, error code 1 prevents the form from being loaded (for form load) or prevents the form from being submitted (for prefile). 

Error code 1 has no effect on the postfile form event.

2 OK/Cancel A message box is displayed with the text of your choice, and choosing OK will act as if error code 1 was chosen and Cancel will act as if error code 1 was chosen. Conditional Actions:

Error codes 2 and 4 provide you with positive and negative responses.

The positive responses (OK and Yes) act as if you had displayed an informational message.

The negative responses (Cancel and No) act as if you had used error code 1.

The same behavior on fields and form-level events happens with the negative responses for error code 2 and for as with error code 1.
3 Informational A message box is displayed with the text of your choice. Displaying messages:

If you need to simply inform the user of something, you can set the error code to 3, and the error message to whatever text you choose.
4 Yes/No A message box is displayed with the text of your choice, and choosing Yes will act as if error code 1 was chosen and No will act as if error code 1 was chosen. 
Note: This is the same behavior as error code 2 with different button labels.
Conditional Actions:

Error codes 2 and 4 provide you with positive and negative responses.

The positive responses (OK and Yes) act as if you had displayed an informational message.

The negative responses (Cancel and No) act as if you had used error code 1.

The same behavior on fields and form-level events happens with the negative responses for error code 2 and for as with error code 1.
5 URL Opens a new browser window with a URL that you specify as the error message. Opening an external web page:
Error code 5 allows you to specify the URL of a web page and have it opened in a new browser window.

Whatever URL you specify will be displayed to the user.
6 Open new form Opens one or more new myAvatar forms that you specify.  This method can’t currently open existing forms for editing. Opening another myAvatar form:
Error code 6 allows you to open one or more new myAvatar forms.

By default, the forms you open will use the PATID and episode number of the form the script is triggered from.
 
Basic format:

The pipe-delimited format for the error message used with error code 6 is:
 
OPTIONID|MESSAGE|Override PATID|Override Episode

OPTIONID is the only required value.

To open a modeled form with the optionID “USER101”, and a message of “Opening our modeled form”, your error message would look like this:
 
USER101|Opening our modeled form


Multiple optionIDs:

You can specify multiple OptionID values to open multiple forms by separating them with the ampersand (&) character.

To open two modeled forms with the optionIDs “USER101” and “CWSPN22000”, and a message of “Opening some forms”, your error message would look like this:
 
USER101&CWSPN22000|Opening some forms

Overriding PATID and episode: To override the PATID and episode number for the forms you are opening, you must specify them.
To open a modeled form with the optionID “USER101”, PATID 2, episode 9, and a message of “Opening a form for another patient”, your error message would look like this:
 
USER101|Opening a form for another patient|2|9

Opening a form in a different namespace:

If you want to open a form in a different namespace (say, opening a CWS form from a script on a PM form), you need to place the namespace of the form you are opening before the optionID.

To open a form in the CWS namespace with the optionID “CWSPN22000” from a form in the PM namespace and no error message, your error message would look like this:
 
[CWS]CWSPN22000

 

  • Was this article helpful?