Hello,
I'm trying to update the description field using this script on Field Change:
// Retrieve initial values of fields
var employee_name = $CS.getValue("ServiceReq_User_UDF_CHAR1");
var responsible = $CS.getValue("WorkOrder_Fields_UDF_CHAR4");
var type_asset = $CS.getText("WorkOrder_Fields_UDF_CHAR5");
var mobile_phone = $CS.getText("WorkOrder_Fields_UDF_CHAR7");
var additional_notes = $CS.getValue("WorkOrder_Fields_UDF_CHAR6");
// Update description with initial field values and user-added notes placeholder
var new_desc = "Please fill mandatory fields (with <span style='color: #FF8888;'>*</span>) related to the services required for our new employee" + "<br>" +
"<br>" +
"You set" + ":" + "<br>" +
"Employee Name: " + employee_name + "<br>" +
"Responsible: " + responsible + "<br>" +
"Type of Asset: " + type_asset + "<br>" +
"Mobile Phone: " + mobile_phone + "<br>" +
"<br>" +
"----------Additional Notes-----------" + "<br>" +
"Notes: " + additional_notes + "<br>";
$CS.setDescription(new_desc);
// Listen for changes in fields and update description accordingly
$CS.addOnChange("ServiceReq_User_UDF_CHAR1", function() {
var updated_employee_name = $CS.getValue("ServiceReq_User_UDF_CHAR1");
new_desc = new_desc.replace(employee_name, updated_employee_name);
$CS.setDescription(new_desc);
employee_name = updated_employee_name;
});
$CS.addOnChange("WorkOrder_Fields_UDF_CHAR4", function() {
var updated_responsible = $CS.getValue("WorkOrder_Fields_UDF_CHAR4");
new_desc = new_desc.replace(responsible, updated_responsible);
$CS.setDescription(new_desc);
responsible = updated_responsible;
});
$CS.addOnChange("WorkOrder_Fields_UDF_CHAR5", function() {
var updated_type_asset = $CS.getText("WorkOrder_Fields_UDF_CHAR5");
new_desc = new_desc.replace(type_asset, updated_type_asset);
$CS.setDescription(new_desc);
type_asset = updated_type_asset;
});
$CS.addOnChange("WorkOrder_Fields_UDF_CHAR7", function() {
var updated_mobile_phone = $CS.getText("WorkOrder_Fields_UDF_CHAR7");
new_desc = new_desc.replace(mobile_phone, updated_mobile_phone);
$CS.setDescription(new_desc);
mobile_phone = updated_mobile_phone;
});
$CS.addOnChange("WorkOrder_Fields_UDF_CHAR6", function() {
var updated_additional_notes = $CS.getText("WorkOrder_Fields_UDF_CHAR6");
new_desc = new_desc.replace(additional_notes, updated_additional_notes);
$CS.setDescription(new_desc);
additional_notes = updated_additional_notes;
});
The Responsible field, is retreived by a lookup using the script on Form Load:
$CS.referField("WorkOrder_Fields_UDF_CHAR4","users",{url:"/api/v3/users"});
Every time a Field change, the description is updated with relative text, but not for responsible. Can you help me to found which is the issue?