Welcome back to another exciting Kaizen post!
The code editor eases the development of a Client Script with several features like
- highlighted syntax
- advanced customization settings
- smart code completions for javascript syntax.
When you save the script, if the Client Script IDE finds errors, the error panel lists the errors at the bottom of the editor.
The Client Script IDE provides the Review component where you can compare and check the differences with the previous code.
You can track the list of saved revisions of your script in the Revision component.
Client Script allows you to execute the script using the Run component. The success message, errors and output of log statements are available in the Messages pane at the bottom of the Run component. Terminal pane, next to the Messages pane allows you to try and execute the ZDK APIs instantly.
You can mask specific information for specific profiles/roles/criteria in Detail Page(Canvas) using the mask() ZDK Client API in Client Script. For example, you can hide the phone numbers of your customers for all profiles except Administrator.
var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);if (user.profile.name !== 'Administrator') {ZDK.Page.getField('Phone_Number').mask({ character: '*', length: 5, reverse: true });}
The following screenshot shows that the Phone Number field is masked partially for a Standard user.
You can auto-populate data for fields whenever the page loads based on any criteria or populate data based on calculations. For example: Auto populate the field Request Name whenever a new record is created in the module Request.
var todaysDate = new Date();
//Append the date with REQ as per requirementvar requestName = "REQ-" + todaysDate.getDate().toString() + "-" + todaysDate.getMonth().toString() + "-" + todaysDate.getFullYear().toString();
//Assign the field "Request Name" to a variablevar reqName_field = ZDK.Page.getField("Request_Name");
//Populate requestName in the field "Name"reqName_field.setValue(requestName);
//Make the field "Request_Name" read-onlyreqName_field.setReadOnly(true);
Using Client Script, you can display custom messages and alerts in Create/Edit/Clone/Detail (Canvas) Page of Zoho CRM. For instance, if you want to display the following message when the user creates a new Account, you can create a Client script on Create Page of Accounts module with onLoad event type and use the ZDK Client API, ZDK.Client.showMessage() in your script. For more samples on displaying custom messages refer to Kaizen #59 .
Using Client Script you can correct, update or modify data instantly after the user enters value in a field. For example, consider that your organisation wants the name of the user to be entered in capital letters, you create a Client Script on Create Page onChange Field event type on field First Name and write a script to auto-convert the name to Capital letters.
var first_name = ZDK.Page.getField("Name");first_name.setValue(value.toUpperCase());
Here is how the Client Script Works.
//To display message
var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);
ZDK.Client.showMessage("Hello " + $Crm.user.full_name +", "+ "Welcome to our Deal Creation Portal");
// To populate Deal Name
var today1 = new Date();
var t1 = "DEAL-" + today1.getDate().toString() + "-" + today1.getMonth().toString() + "-" + today1.getFullYear().toString();
log(t1);
var deal_field = ZDK.Page.getField("Deal_Name");
deal_field.setReadOnly(true);
deal_field.setValue(t1);
|
Writer is a powerful online word processor, designed for collaborative work.