Contains all the methods for custom scripting on a screen
- Source:
Methods
-
.addButton(options)
-
Adds a custom button to the screen
Parameters:
Name Type Description options
object Specify the options for this method.
Properties
Name Type Argument Default Description screenId
String Specify the id of the screen.
buttonName
String Specify the unique name for the button.
iconUrl
String <optional>
"defaultFunction" Specify the url of the icon.
label
String Specify the text to show on the button.
onClick
function Specify the script to execute when the button is clicked.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId, buttonName, label, onClick)
-
Will throw an error when a component with the passed screenId could not be found.
Returns:
The name of the button.
- Type
- String
Example
CSL.screen.addButton({ screenId: sourceId, buttonName: "Go to Google", iconUrl: "fa-google", label: "Go to Google", onClick: function(){ window.open("//google.com"); } })
-
.addScreen(options)
-
Parameters:
Name Type Description options
Object Specify an options object.
Properties
Name Type Argument Default Description componentId
string Specify the id of the component to add the screen to
grid
Object Specify the source grid that opened the screen.
object
string Specify the object.
view
string Specify the view.
viewDefinition
Array.<Object> <optional>
Specify the view definition object. This can be used to override the default viewDefinition of a view.
viewFields
Array.<Object> <optional>
Specify the viewField configurations you want to use in the screen. This can be used to override the default viewFields of a view.
parentScreenId
String <optional>
Specify the id of the parent screen.
dataItem
Array.<Object> <optional>
Specify the context data items from the update, display or grid.
prepareView
bool <optional>
false Specify if the screen should make a prepareView request.
- Source:
Returns:
The unique identifier of the newly created screen
- Type
- String
-
.close(options)
-
This function closes the given screen. Be aware that this does not save the screen.
Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId).
-
Will throw an error when a component with the passed screenId could not be found.
Example
CSL.screen.close({ screenId: sourceId });
-
.deleteRecord(options)
-
This function triggers the delete function of a view if there is one configured.
Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId).
-
Will throw an error when a component with the passed screenId could not be found.
Returns:
A promise because REST calls are being made. Is resolved when the function completed successfully.
- Type
- Promise
Example
var deletePromise = CSL.screen.deleteRecord({ screenId: sourceId });
-
.executeFunction(options)
-
This function executes the given function on the screen.
Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
functionName
string Specify the name of the function.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId and functionName).
-
Will throw an error when a component with the passed screenId could not be found.
-
Will throw an error if the passed in function could not be found on the screen.
Returns:
A promise because REST calls are being made. Is resolved when the function completed successfully.
- Type
- Promise
Example
CSL.screen.executeFunction({ screenId: sourceId, functionName: "Copy" });
-
.hasButton(options)
-
Checks whether the screen has a custom button with the given name.
Parameters:
Name Type Description options
Object Specify the options for this method.
Properties
Name Type Description screenId
String Specify the id of the screen.
buttonName
String Specify the unique name for the button.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId, buttonName)
-
Will throw an error when a component with the passed screenId could not be found.
Returns:
True if a button already exists, false if not.
- Type
- Boolean
Example
var buttonExists = CSL.screen.hasButton({ screenId: sourceId, buttonName: "Go to Google" });
-
.openCreate(options)
-
This function opens the create view of a screen if there's one configured.
Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId).
-
Will throw an error when a component with the passed screenId could not be found.
-
Will throw an error when there's no create view configured on the screen.
Returns:
The screen configuration of the newly opened create screen.
- Type
- Object
Example
var screenConfig = CSL.screen.openCreate({ screenId: sourceId });
-
.openUpdate(options)
-
This function opens the update view of a screen if there's one configured.
Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId).
-
Will throw an error when a component with the passed screenId could not be found.
-
Will throw an error when there's no update view configured on the screen.
Returns:
The screen configuration of the newly opened update screen.
- Type
- Object
Example
var screenConfig = CSL.screen.openUpdate({ screenId: sourceId });
-
.progress(options)
-
Shows or hides the progress indicator on the screen.
Parameters:
Name Type Description options
object Specify the options for this function.
Properties
Name Type Argument Default Description screenId
string Specify the unique identifier of the screen.
progress
boolean <optional>
true Specify whether the progress indicator should be shown or hidden.
- Source:
Examples
CSL.screen.progress({ screenId: sourceId });
CSL.screen.progress({ screenId: sourceId, progress: false });
-
.removeButton(options)
-
Removes a custom button on the screen with the given name.
Parameters:
Name Type Description options
Object Specify the options for this method.
Properties
Name Type Description screenId
String Specify the id of the screen.
buttonName
String Specify the unique name for the button.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId, buttonName)
-
Will throw an error when a component with the passed screenId could not be found.
Example
CSL.screen.removeButton({ screenId: sourceId, buttonName: "Go to Google" });
-
.save(options)
-
This function saves the given screen if it is an insert or update screen. The form will be validated before the actual save request is performed.
Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId).
-
Will throw an error when a component with the passed screenId could not be found.
Returns:
A promise for the saving process. If the promise is resolved, the form has been saved.
- Type
- Promise
Example
CSL.screen.save({ screenId: sourceId });
-
.validate(options)
-
This function validates the given screen if it is an insert or update screen. No error handling on validation is necessary because if the view field is invalid
the error will be set on the view field.Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId).
-
Will throw an error when a component with the passed screenId could not be found.
Returns:
A promise for the validation process. If the promise is resolved, the form is valid.
- Type
- Promise
Example
CSL.screen.validate({ screenId: sourceId }).then(function(){ // We're valid }).catch(function(){ // We're invalid or an error occurred in the .then callback })
-
.values(options)
-
This function gets or sets the given screen values. If the values parameter is passed, the values will be set if the view field is found on the screen.
Parameters:
Name Type Description options
Object Specify the options for this function.
Properties
Name Type Description screenId
string Specify the unique identifier of the screen.
- Source:
Throws:
-
Will throw an error if any required input field is not set (screenId).
-
Will throw an error when a component with the passed screenId could not be found.
Returns:
The values of the screen.
- Type
- Object
Example
var formValues = CSL.screen.values({ screenId: souceId });