The aim of this document is to clarify the field and form rules through practical examples. The subsequent sections will walk you through the detailed process of configuring various use cases, accompanied by relevant screenshots.
When a country is selected, the system should automatically populate the available clusters for that country.
When a cluster is selected, the Cluster Head field should automatically populate with the available Cluster Head in that city.
Step 1 :- Creating additional fields such as Country/Cluster/Cluster Head
To address the above use case, we first need to include fields (Country, Cluster, and Cluster Head) with appropriate values in Incident Additional Fields. Afterwards, these fields should be added to a template (such as the Default Template), as depicted in the image below:
Step 2 :.
Create a new rule under the "On Form Load" event.
Since the dependency is created under the "On Form Load" event, it will only be created when the form is loaded.
Choose "Applies to All Users" to ensure that the dependency applies to all users (both Technicians and Requesters).
4. Create a rule without any condition to clear the values of the Cluster and Cluster Head fields as shown in the below screenshot.
5. Create a rule to display the values of the Cluster field based on the field change of the Country field
.
6. Create a rule to display the values of the Cluster Head field based on a specific Cluster value.
7. Create similar rules to display the values of the Cluster Head field for each of the other specific Cluster values.
Steps to be followed :-
Create a new rule under the "On Form Load" event with the name say for example "Disable & Mandate CSI"
Set the Rule Execution to "On Create".
Set the rule to "Applies to Requesters".
No conditions are required at this stage (conditions can be specified later if needed on field change).
Under actions, add an action to disable the Cluster Head field.
Add another action to mandate the Category and Sub Category fields.
Technicians want their name to be loaded in the requester's name field whenever they load the form, without requiring them to choose the requesters manually unless it is necessary.
Example:
If requesters create a request, it loads their name by default.
If technicians load a form, it leaves the space empty, allowing them to select the requester's name.
Steps to be followed :-
Navigate to the Set up → Templates and Forms → Form rules
Select Rule applies to all "Technicians"
Execute when a request is "Created"
Select without "Any conditions"
Add actions as "Execute custom script" and add the below script.
Custom Script to load the logged in technician name and site as requester :-
var CS_context = CS.dataStore.get("CS_context");
var userInfo = CS_context.userInfo;
if(userInfo != null && userInfo.is_technician && userInfo.id != null) {
CS.setValue("requester",{"id":userInfo.id,"name":userInfo.name});
//
debugger;
var requester_data = await CS.API.get('/api/v3/requests/requester/' + userInfo.id);
requester_data = JSON.parse(requester_data);
requester = requester_data.user;
CS.setValue("site", requester.site);
CS.end();
}
On change of the Impact field, mandate the Impact Details field, applicable to all users, and execute on Create/Edit.
Steps to be followed:
Create a new rule under "On Field Change" event (say, "on change of impact mandate impact details") .
Select "Applicable to All Users".
Select "On Create / Edit".
Select the Field as "Impact", as shown in the below image:
Under Conditions, add a condition as Impact is Affects Business.
Under Actions, add an action as Mandate Field: Impact Details
Save the Rule.
Steps to be followed:
Create a new rule under the "On Form Submit" event.
Select "Applicable to All Users".
Select "On Create".
No conditions are required at this stage
Under Actions, add an action as Execute script and add the below script.
Save the Rule.
Script used for scenario A :-
var subj = await CS.getValue("subject");
var cat = await CS.getValue("category");
var subcat = await CS.getValue("subcategory");
var sub = cat.name + " " + subcat.name;
CS.setValue("subject", subj + " " + sub);
CS.end();
Create a new rule under the "On Form Submit" event (say, "on change of impact mandate impact details") .
Select "Applicable to All Users".
Select "On Create/Edited".
Select condition as the Scheduled End Time is not empty.
Under Actions, add an action as Execute script and add the below script.
Save the Rule.
Script used for scenario B :-
var endTime = await CS.getValue("scheduled_end_time");
var startTime = await CS.getValue("scheduled_start_time");
console.log("endTime = "+endTime +" startTime = " +startTime);
if(endTime != null && startTime != null){
var diff = Math.round((endTime.value-startTime.value)/(1000*60*60*24));
if(diff>3){
var confirm= await CS.confirm("Schedule End should be within 3 days., Still do you want to proceed?");
if(!confirm){
CS.clearValue("scheduled_end_time");
CS.abort();
}
}
}
CS.end();
Steps to be followed :-
Create a new rule under the "On Form Submit" event
Select "Applicable to All Users".
Select "On Create".
Select condition as Category and Logged in User (You can have it changed depending on your requirement)
Under Actions, add an action as Execute script and add the below script.
Save the Rule.
Script used for scenario C:-
async function checkValueandAbort(){
var category = await CS.getValue('category');
if(category.name == 'Active Directory'){
await CS.alert('Aborting Form Submit');
CS.abort();
}
}
CS.onFormSubmit(function(){
checkValueandAbort();
});
CS.end();
When HR submits a service request form for onboarding a new employee, the system should automatically append the first name and last name of the employee to the subject line of the request. This enhancement aims to streamline the identification process, making it easier for the team to recognize quickly and process onboarding requests.
For example, if HR submits a request for John Doe, the subject line would be updated to "Onboarding Request: John Doe." So the first name and last name is the custom field created under Set up → Customization → Additional fields → Request.
Steps to be followed :-
Create a new rule under the "On Form Submit" event
Select "Applicable to All Users".
Select "On Create".
Uncheck the "Condition" as no condition is required for this request.
Under Actions, add an action as Execute script and add the below script.
Save the Rule.
Script used for the above scenario D :-
var subject = await CS.getValue("subject");
var fn = await CS.getValue("udf_fields.udf_char10");
var ln = await CS.getValue("udf_fields.udf_char2");
var fnln = fn + " " + ln;
CS.setValue("subject", subject + " - " + fnln);
CS.end();