Helper Functions

 
Helper functions can be entered manually or by selecting them when the Quick Code option is selected in the advanced options of a Calculate Field, or JavaScript Button Control.  They enable the script developer to use a single function to show, hide, enable, disable or suppress MULTIPLE fields on the page, rather than using GetCSObject command in a row for each field.
 
Name
Description
Code
disableFields
Disables field(s).  The field will be "greyed-out".  Any text within it will be displayed, but cannot be edited.
disableFields('[field1]','[field2]','[…field10]');
enableFields
Enables field(s).  Enables fields previously hidden using disbleFields() function
enableFields('[field1]','[field2]','[…field10]');
showFields
Shows fields that have been previously hidden.
showFields('[field1]','[field2]','[…field10]');
supressFields
Suppress (hide) the specified field AND the space it previously occupied.
supressFields('[field1]','[field2]','[…field10]');
hideFields
Hides the specified fields but retains the place previously occupied by the field.
hideFields('[field1]','[field2]','[…field10]');
 
 

Other Functions

Name
Description
Code
csc Check Email
Checks whether a specified field contains a valid email address or if it is blank.  Alerts the user if the address is invalid
if( [E-mail Address] != '' )
{
if(([E-mail Address].search(/[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+.[A-Za-z0-9_.-]+/gi) != 0))
{
alert('Valid e-mail address please or leave blank')
}
}
csc else
Inserts an else statement
else
{
 
}
csc if
Inserts an if statement
If ()
{
 
}
csc try/catch
Inserts a try/catch statement so you can test a section of code for errors.
 
try
{
 
}
catch(e)
{
 
}
csc uname
Concatenates the fields [firstname] and [surname] into the variable [var_username] with a space in between
[var_username] = [firstname] + ' ' + [surname];
getCSObject
Function to return the control as an object. This result can be used in the same way as document.getElementById in a normal web form. The id's and name's of the controls in CallScripter are forever changing so this function needs to be used.
getCSObject([Control Name]);
 
After the element has been accessed you can then use it's properties:
 
getCSObject([Control Name]).style.width = '30px';
 
This example will set the width of the control to 30px
ltrim
Trims any blank space from the left hand of a string
[Field] = ltrim([Field]);
money
Rounds a float number to two decimal places so it can be displayed as a monetary value.  E.g., 1.00/3 = 0.33333333 the result will be displayed as 0.33
[Field] = money([Field]);
numOnly
Removes any text characters from the string leaving only numbers.
[Field] = numOnly([Field]);
parseFloat
Converts the content of a text field as a float.  A float is a number with decimal places.  You must convert numbers in text fields in order that they can be added together.
parseFloat('[field1]')
pcase
Converts the string to proper case
[Field] = pcase([Field]);
rtrim
Trims any white space from the right of a string
[Field] = rtrim([Field]);
tcase
Converts the text to Sentence case.  Capitalises the first letter and makes following text lower case.
[Field] = tcase([Field]);
 
trim
Trims space from either end of a text string.
[Field] = trim([Field]);