Helper functions can be entered the same as any other JavaScript code in Calculate Field, JavaScript, or JavaScript Button controls. They enable the Workflow builder to use a single function to perform complex actions on the Workflow page, such as showing, hiding, or suppressing multiple fields. They are split into groups based on their category, and briefly described below - for further detail and examples please see the Knowledge Base.
Please note that all of these functions are documented for the current release of Scripting, and for the most up-to-date System Controls. They may be incompatible with older releases of Scripting, or Custom/outdated Controls.
These functions allow the manipulation of a temporary data stash that exists only within that session. The stash is pre-populated by pop data passed via External Links, if enabled, or specified in a Pop, and can be freely read or written to during the Workflow run. Note that when used in a Workflow popped from the Social Dashboard, this holds a structured data object populated with the data returned from the Social provider that is used to build the displayed content.
Name
|
Description
|
Code
|
Script.Data.GetPostData
|
Returns the entire data stash as a JavaScript object, formatted as a list of key:value pairs.
|
= Script.Data.GetPostData();
|
Script.Data.GetPostDataItem
|
Returns the value of the particular data item identified by the supplied key. Key must be provided as a string.
|
= Script.Data.GetPostDataItem("");
|
Script.Data.SetPostDataItem
|
Sets the value of the particular data item identified by the supplied key. Key must be provided as a string.
|
Script.Data.SetPostDataItem("", );
|
These functions are used to manage Workflow fields.
Name
|
Description
|
Code
|
Script.Fields.Enable
|
Enables field(s). Enables a field previously hidden using the Script.Fields.Disable() function.
|
Script.Fields.Enable("","","");
|
Script.Fields.Disable
|
Disables field(s). The field will be "greyed-out". The field can no longer be interacted with by the agent, but the field is still visible and any information contained within them is still visible.
|
Script.Fields.Disable("","","");
|
Script.Fields.Hide
|
Hides the specified field(s) but retains the place previously occupied by the field.
Note: if the height of a control is altered while hidden (such as the text in a Text Label being altered), the gap where the hidden control is placed will also alter in height.
|
Script.Fields.Hide("","","");
|
Script.Fields.IsEnabled
|
Returns true or false depending on whether the provided Field is enabled or disabled. If the Field isn't recognise, then it returns undefined.
|
Script.Fields.IsEnabled();
|
Script.Fields.IsVisible
|
Returns true or false depending on whether the provided Field is visible or hidden/suppressed. If the Field isn't recognise, then it returns undefined.
|
Script.Fields.IsVisible();
|
Script.Fields.NavigateIFrame
|
Allows the setting or alteration of an IFrame's destination URL.
|
Script.Fields.NavigateIFrame("", "");
|
Script.Fields.ReadOnly
|
Sets/unsets field(s) as Read Only. The field will appear visually the same as a normal field when Read Only. The field can no longer be interacted with by the agent, but the field is still visible and any information contained within them is still visible. Provides same functionality as found in the Field Properties.
|
Script.Fields.ReadOnly(, "","");
Script.Fields.ReadOnly(, "","");
|
Script.Fields.Show
|
Shows field(s) that have been previously hidden or suppressed.
|
Script.Fields.Show("","","");
|
Script.Fields.Suppress
|
Suppress (hide) the specified field(s) AND the space it previously occupied.
|
Script.Fields.Suppress("","","");
|
These functions are used to format data.
Name
|
Description
|
Code
|
Script.Fields.Data.AlphaOnly
|
Removes any non-English alphabet characters from a string.
For example:
Script.Fields.Data.AlphaOnly("")
|
= Script.Fields.Data.AlphaOnly();
|
Script.Fields.Data.NumbersOnly
|
Removes any non-numeric characters from a string.
For example:
Script.Fields.Data.NumbersOnly("")
|
= Script.Fields.Data.NumbersOnly();
|
Script.Fields.Data.Money
|
Takes a number or numeric string, and returns it as a numeric string formatted with two decimal places
For example:
Script.Fields.Data.Money()
Script.Fields.Data.Money()
|
= Script.Fields.Data.Money();
|
Script.Fields.Data.LeftTrim
|
Removes any whitespace from the left end of a string.
|
= Script.Fields.Data.LeftTrim();
|
Script.Fields.Data.RightTrim
|
Removes any whitespace from the right end of a string.
|
= Script.Fields.Data.RightTrim();
|
Script.Fields.Data.Trim
|
Removes any whitespace from both ends of a string.
|
= Script.Fields.Data.Trim();
|
Script.Fields.Data.ProperCase
|
Capitalises the first letter of every word, makes every other character lower case.
For example:
Script.Fields.Data.ProperCase("")
Script.Fields.Data.ProperCase("")
|
= Script.Fields.Data.ProperCase();
|
Script.Fields.Data.StartCase
|
Alias for Script.Fields.Data.ProperCase
|
= Script.Fields.Data.StartCase();
|
Script.Fields.Data.TitleCase
|
Capitalises the first letter of a sentence, leaves every other character unchanged.
For example:
Script.Fields.Data.TitleCase("")
Script.Fields.Data.TitleCase("")
Script.Fields.Data.TitleCase("")
|
= Script.Fields.Data.TitleCase();
|
These functions are documented under SMS.
These functions are used to fulfil a variety of purposes, including validation.
Name
|
Description
|
Code
|
Script.Utils.ChangeRecordReference
|
Alters the campaign reference for the current Workflow run to the provided value. The new value must still be unique within the campaign.
Note that when the function completes, it triggers the Workflow to run calculations again.
|
Script.Utils.ChangeRecordReference();
|
Script.Utils.GetAllFieldsAndVariables
|
Returns a JavaScript object of all Fields on the page, and all variables in the Workflow. The object is formatted with the Field or variable name as the Key, and the Field or variable's value as the Value.
For example:
{Caller Name:"Joe Bloggs", var_csAgentName:"Jane Doe"}
|
= Script.Utils.GetAllFieldsAndVariables();
|
Script.Utils.GetCSObject
|
Function to return the field as an HTML DOM element. This result can be used in the same way as document.getElementById in a normal web form.
|
Script.Utils.GetCSObject();
After the element has been accessed you can then use its properties/actions. For example, to click a button:
Script.Utils.GetCSObject().click();
|
Script.Utils.GetGuid
|
Returns a GUID containing both letters and numbers, of the form XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
For example:
5D3F830A-ADA8-4568-9AAC-26E7263C6103
|
= Script.Utils.GetGuid();
|
Script.Utils.GeneralException
|
Pops up an error modal containing user-defined text, and immediately ends the Workflow. Accepts two parameters, which are displayed in the error modal as text - typically, used as a heading or class, and then a descriptive section.
|
Script.Utils.GeneralException("", "");
|
Script.Utils.isJson
|
Returns true or false depending on whether the supplied thing is a JSON string.
For example:
Script.Utils.isJson('{"key":"value"}')
Script.Utils.isJson({key:"value"})
Script.Utils.isJson("Hello")
|
if (Script.Utils.isJson()) {
}
|
Script.Utils.isNullOrWhiteSpace
|
Returns true or false depending on whether the supplied thing is undefined/null/composed entirely of whitespace, or not.
For example:
Script.Utils.isNullOrWhiteSpace(undefined)
Script.Utils.isNullOrWhiteSpace(" ")
Script.Utils.isNullOrWhiteSpace("Hello")
|
if (Script.Utils.isNullOrWhiteSpace()){
}
|
Script.Utils.isNumeric
|
Returns true of false depending on whether the supplied thing is numeric or not.
For example:
Script.Utils.isNumeric(3)
Script.Utils.isNumeric("10.2")
Script.Utils.isNumeric("Hello")
|
if (Script.Utils.isNumeric()){
}
|
Script.Utils.StartsOrEndsWithSpace
|
Returns true or false depending on whether the supplied string has any leading or trailing whitespace.
For example:
Script.Utils.StartsOrEndsWithSpace("Hello")
Script.Utils.StartsOrEndsWithSpace(" Hello")
Script.Utils.StartsOrEndsWithSpace("Hello ")
Script.Utils.StartsOrEndsWithSpace(" Hello ")
|
if (Script.Utils.StartsOrEndsWithSpace()){
}
|
Script.Utils.StringFormat
|
Allows the construction of a string with a placeholders replaced by supplied parameters. May result in easier-to-read code in some cases when trying to assemble large strings with many dynamic elements.
For example:
String.Utils.StringFormat("Hello, my name is {0}. {0} is short for {1}, and my username is {2}", "Joe", "Joseph", [var_csAgentUserName]);
|
= String.Utils.StringFormat(, , );
|
Script.Utils.Navigate
|
Triggers page transition to the named Workflow page. Be aware that this doesn't fire page validation, and isn't detected by Workflow checking (potentially leading to warnings of unlinked pages).
|
Script.Utils.Navigate();
|
Script.Utils.UpdateFieldOrVariable
|
Allows the setting of a Workflow Field on the current page, or Variables.
The first parameter is a string of the Field or Variable name (excluding the surrounding square brackets).
The second parameter is a string of the value to be set to the Field or Variable.
|
Script.Utils.UpdateFieldOrVariable(, );
|
Script.Utils.UpdateMultipleFields
|
Allows the immediate setting of the value of any Workflow field, regardless of whether it's on the current page or not. It cannot be used to set the value of Variables.
The first parameter is a JavaScript object containing a dictionary of Field names and the values they are to be set to.
The second parameter is an optional "callback" function that can be used to execute further JavaScript once the function has completed.
|
Script.Utils.UpdateMultipleFields(,
);
|
Script.Utils.ValidatePage
|
Runs page validation on any Fields that have validation enabled. Any Fields that fail the validation will be highlighted in red until remedied. It accepts a boolean (true/false) argument that controls whether the normal "validation failed" warning modal is hidden or not.
Script.Utils.ValidatePage(true);
Script.Utils.ValidatePage(false);
|
if (Script.Utils.ValidatePage()) {
}
|
Name
|
Description
|
Code
|
Script.CancelRecord
|
Allows the immediate cancellation of all outstanding activities relating to a provided Outbound ID, including any pending reschedules, unsent messages, or incomplete records or transfers. This function is only intended for use with records that aren't being actively run by an agent at the time. There is also an identical Desktop.CancelRecord() helper function, for use by plugins and non-Workflow development..
The first parameter is the Outbound ID that will have all related activities cancelled.
The second parameter is the outcome, a string that will be stamped on the relevant closure entries.
The third parameter is an optional string of the connector type to mark as having initiated the closure.
The fourth parameter is an optional string of the connector name to mark as having initiated the closure.
|
Script.CancelRecord(, "", "
", "");
|
Script.Finish
|
An object-based variant of Script.FinishScript.
outcome: A string used to determine the Workflow run's disposition.
preserveState: A boolean (true/false) of whether to preserve the Workflow state.
preserveToolbar (Optional): A boolean of whether to retain the Workflow as an in-progress activity. If this is true, it will override the preserveState parameter to also be true.
|
Suspend the current Workflow, allowing the agent to resume it at will:
Script.Finish({outcome:"", preserveState:, preserveToolbar:, comments:});
|
Script.FinishScript
|
Allows the immediate closure or suspension of the current Workflow run, with the option to preserve the Workflow state in the database. If the Workflow state is preserved, the Workflow run can be resumed at a later date (via a method like JavaScript Pop, and even left in a suspended state that the agent can resume at will. If this method is used, then record data isn't submitted to any integration that may have been linked to the Workflow.
The first parameter is the outcome, a string used to determine the Workflow run's disposition.
The second parameter is a boolean (true/false) of whether to preserve the Workflow state.
The third parameter is an optional boolean of whether to retain the Workflow as an in-progress activity. If this is true, it will override the second parameter to also be true.
The fourth parameter is an optional comment to attach to this history entry, a string that can be reported on via Data Extracts.
|
Close the current Workflow, leaving the disposition as "Transferred" and the Workflow ready to be resumed in the future:
Script.FinishScript("", );
Suspend the current Workflow, allowing the agent to resume it at will:
Script.FinishScript("", , , "");
|
Script.GetCurrentUser
|
Returns a JavaScript object that contains various information about the current user. Requires no parameters, but some of the items in the returned object are listed below.
AssignedGroups: an array of objects, each containing the ID and name of the user's groups.
AssignedParts: an array of the licences that have been assigned to the user.
Attributes: an object of any System Attributes have been added to the users, in name:value pairs.
|
Pop a toast alert to users in a particular group.
Script.GetCurrentUser()
|
Script.CTI.DisconnectOnClose
|
Determines whether the interaction should be closed automatically at the end of the Workflow run or not. This allows the override of any global setting in CTCallDisconnectOnClose (default is true) on a per-Workflow basis.
If set to true, the interaction will be closed on Workflow completion.
If set to false, the interaction won't be closed on Workflow completion.
|
Script.CTI.DisconnectOnClose();
|
Script.Info.GetSessionId
|
Returns the Session ID of the current Workflow run, similarly to [var_csSessionID].
|
= Script.Info.GetSessionId();
|
Script.Info.GetScriptId
|
Returns the Workflow ID of the current Workflow run, similarly to [var_csScriptID].
|
= Script.Info.GetScriptId();
|
|