Follow

Web Control Scripting API

This article provides an overview of the Capriza Web Control Scripting API, which can be leveraged to implement complex actions and automations within your Zapp. Please see Advanced Automation Features for more information on using the Web Control Scripting API.

 

Access

 

In all the available Scripting hooks, you can also access the current page’s web controls, either directly given its unique name*: 

 

var wc = context.getControl(UNIQUE_NAME);

 

Or by iteration:

 

var wc = context.controls.forEach(wc =>...);

 

*Note: The unique name of each web control can be found in the header of the web properties dialog, which is accessed by clicking the wrench icon in Simplify mode. Please see Naming a Control for more information.

 

General Properties

 

The following general properties are supported when calling the WebControl Scripting API.

 

Property

Description

id

The control's unique name.

valid

Indicates if a control is currently available on the page.

 

Data Properties

 

The following data properties are supported when calling the Web Control Scripting API, based on the role of the control (e.g. any input can have a “disabled” property, only checkboxes have a “checked” property, etc.).

 

Property

Description

disabled

Indicates if a control is disabled.

readOnly

Indicates if a control is read only.

label

The control's label.

tooltip

The tooltip text specified for the control. This text renders when Zapps are run on desktop or mobile devices with accessibility features enabled.

error

Either indicates whether the control is in error state (boolean) or an error message (string).

textContent

The text content of the control.

imageSrc

The source URL of an image control.

text

The value of a text input control.

checked

The checked state of a checkbox control.

date

The date as input into a date picker control.

selectedIndex

The selected index of a dropdown control.

items

The items list of a dropdown control.

 

Functions

 

The following functions can be called with the Web Control Scripting API, based on the role of the control:
 

Function

Parameters

Description

click()

null

Clicks the specified control.

setText()

text

Sets a control's text to the specified value.

setChecked()

boolean

Checks/unchecks the specified checkbox control.

setDate()

date

Sets a date picker control to the specified date.

setSelectedIndex()

integer

Sets the selected index of a dropdown control.

 

Note: The functions are asynchronous, so they can be used only in asynchronous operations like method overrides and automations but not in property overrides.

 

Example Script

 

The following example script takes a Sales Opportunity Zapp with three fields: Probability, Amount, and Description and changes the value of Description based on the other two fields.

 

var probValue = context.getControl('prob').text;
var amountValue = context.getControl('amount").text;
var descWC = context.getControl('prob');
descWC.setText('Evaluated amount: ' + probValue * amountValue / 100).then(resolve);

 

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.