Field

Class representing a Field in a Page.

Functions

#

getApiName() → {String}

Get the API name of field

api_name

String
Examples

SampleCopycopied

var field_obj = ZDK.Page.getField('Created_Time');
field_obj.getApiName();

Output

Created_Time

# Detail Page (Canvas) Detail Page (Standard)

mask()

Mask the field value

Examples

Sample 1Copycopied

var field_obj = ZDK.Page.getField('Email');
field_obj.mask({character: '*', length: 4, reverse: false});

Output in UI

****rt@zohomail.com

Sample 2Copycopied

var field_obj = ZDK.Page.getField('Email');
field_obj.mask({character: '#', length: 8, reverse: true});

Output in UI

robert@zoho########

# Create / Edit / Clone Pages Detail Page (Canvas)

showError(message)

Show inline error message for an input field. In canvas detail page, supported only in Ajax edit and Mandatory form.

Parameters:
Name Type Description
message String

Text to be displayed

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Created_Time');
field_obj.showError('Invalid value');

# Create / Edit / Clone Pages Detail Page (Canvas) Detail Page (Standard)

setValue(value)

Set the value for a field. In canvas/standard detail page, supported only in Mandatory form.

Parameters:
Name Type Description
value String | Number | Boolean | Object

Value for the field

Examples

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.setValue('Value');

For Lookup fieldsCopycopied

var lookup_field = ZDK.Page.getField('Account_Name');
lookup_field.setValue({id: "5164254000000366162", name: "John Doe"});

For Checkbox fieldsCopycopied

var checkbox_field =  ZDK.Page.getField('Email_Opt_Out');
checkbox_field.setValue(true); // true/false -> enable/disable

For Subform fieldsCopycopied

var subform_field = ZDK.Page.getField('Subform_1');
subform_field.setValue( [ {
Name_1: 'John Doe',
Email_1: 'john@zylker.com',
Website_1: 'www.johnzylker.com'
} ] );

# Create / Edit / Clone Pages Detail Page (Canvas) Detail Page (Standard)

getValue() → {String|Number|Boolean|Object}

Get the value of a field

Value of the field

String | Number | Boolean | Object
Examples

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.getValue();

Output

zylker@zylkergp.com

For Lookup fieldsCopycopied

var lookup_field = ZDK.Page.getField('Account_Name');
lookup_field.getValue();

Output

{id: '5164254000000366162', name: 'John Doe'}

For Subform fieldsCopycopied

var subform_field =  ZDK.Page.getField('Subform_1');
subform_field.getValue();

Output

[{
Name_1: 'John Doe',
Email_1: 'john@zylker.com',
Website_1: 'www.johnzylker.com'
}]

# Create / Edit / Clone Pages

setMandatory(value)

Set the mandatory attribute for the input field

Parameters:
Name Type Description
value Boolean

mandatory attribute of the field input(true/false)

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.setMandatory(true);

# Create / Edit / Clone Pages Detail Page (Canvas) Detail Page (Standard)

setMaxLength(value)

Set the max Length of field input

Parameters:
Name Type Description
value Number

max length of the field input

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.setMaxLength(10);

# Create / Edit / Clone Pages Detail Page (Canvas) Detail Page (Standard)

setReadOnly(value)

Set the readonly attribute of field input

Parameters:
Name Type Description
value Boolean

readonly attribute of the field input(true/false)

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.setReadOnly(true);

# Create / Edit / Clone Pages Detail Page (Standard)

setVisibility(value)

Show/Hide field

Parameters:
Name Type Description
value Boolean

visibility attribute of the field input(true/false)

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.setVisibility(true);

# Detail Page (Standard)

addStyle(style_config)

Show highlighted message on field

Parameters:
Name Type Description
style_config Object

style_config to be added to the field

backgroundColor '#FF0000'

sets the background color of an element.

foregroundColor '#FF0000'

sets the foreground color value of an element's text

borderColor '#FF0000'

sets the color of an element's border.

fontWeight 'bold' | '100' | 'inherit'

sets the thickness (weight) of the text's character.

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.addStyle({ backgroundColor: '#ff0000', foregroundColor: '#fff000', borderColor: '#ffff00' });

# Create / Edit / Clone Pages Detail Page (Standard)

addInfo(message)

Set the info icon to field

Parameters:
Name Type Description
message String

message/info to be added

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.addInfo("Shows custom info");

# Create / Edit / Clone Pages Detail Page (Standard)

addTooltip(message)

Set tootip to field

Parameters:
Name Type Description
message String

message to be added

Example

SampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Field1');
field_obj.addTooltip("Shows custom info");

# Create / Edit / Clone Pages Detail Page (Standard)

setCriteria(criteria, config)

Set the criteria for lookup/picklist fields

Note: lookup/picklist fields and date range field support a maximum of 5 and 1 criteria respectively. Detail Page supports only lookup fields.

Parameters:
Name Type Attributes Description
criteria String

criteria for filtering lookup records

config Object <optional>

config for lookup field criteria

Examples

Lookup sampleCopycopied

var field_obj = ZDK.Page.getField('Custom_Lookup1');
field_obj.setCriteria("((Last_Name:equals:Burns)and(First_Name:starts_with:M))", {filterOnSearch: true});

Picklist sample with idCopycopied

var field_obj = ZDK.Page.getField('CFPicklist');
field_obj.setCriteria("((id:in:12111113441,12111113443))");

Picklist sample with valueCopycopied

var field_obj = ZDK.Page.getField('CFPicklist');
field_obj.setCriteria("(actual_value:starts_with:Industry)");

Date field rangeCopycopied

var field_obj = ZDK.Page.getField('Date_1');
field_obj.setCriteria("(value:between:2023-04-18,2023-04-25)");

# Create / Edit / Clone Pages

getPicklistOptions()

Get the list of options for picklist/multiselect picklist fields

Examples

SampleCopycopied

var field_obj = ZDK.Page.getField('Lead_Status');
field_obj.getPicklistOptions();

Output

[
 { "display_value": "-None-", "actual_value": "-None-" },
 { "id": "111111000000014736", "filtered": false, "display_value": "Attempted to Contact", "actual_value": "Attempted to Contact" },
 { "id": "111111000000014730", "filtered": false, "display_value": "Contact in Future", "actual_value": "Contact in Future" }
 { "id": "111111000000014732", "filtered": false, "display_value": "Contacted", "actual_value": "Contacted" }
]