So here is the scenario, on my incident table I have a field called “Escalated” and I have another field called “Escalated Time”.
Requirement is “when user choose escalated field to “Yes”, escalated time should automatically populate (Click the image below to expand)

How did I achieve this requirement is by creating an on change client script on incident table.
(click the image below)

Attaching the full code below (In case if you have any doubt check the commented part for more details)
var escstate = g_form.getValue(‘u_escalated’);
var currentDate = new Date(); //Fri Apr 19 2024 12:38:06 GMT+0200 (Central European Summer Time
//Output I want in this format >> 2024-04-19 12:40:15
//below code will convert the date to how I want
var formatedDate = new Date().getFullYear()+’-‘+(“0″+(new Date().getMonth()+1)).slice(-2)+’-‘+(“0″+new Date().getDate()).slice(-2)+ ‘ ‘ + (“0″+new Date().getHours()).slice(-2)+’:’ + new Date().getMinutes()+ ‘:’+ new Date().getSeconds();
//alert(formatedDate);
//below code will show date to the field on incident
if (escstate == ‘true’) {
g_form.setValue(‘u_escalated_time’, formatedDate);
}
Share