Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Help with Client Script to update the Work_Notes on the Incident Form

alhicks
Tera Guru

Can the below script be changed to update the work_notes with the "u_reassign_reason" which is a drop down list? We get the popup box to select a reason that the Help Desk is assigning the incident to another group, we'd like for the value from the reason be updated to the work_notes on the incident.

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(g_form.isNewRecord()){
if (g_form.getValue('assignment_group') != '8051349c0a0a3c1f005d2bbd78082b2d') {
g_form.setDisplay('u_reassign_reason',true);
g_form.setMandatory('u_reassign_reason',true);
alert("Reassign reason is mandatory");
}
else {
g_form.setDisplay('u_reassign_reason',false);
g_form.setMandatory('u_reassign_reason', false);

}
}
}

9 REPLIES 9

ShaneBrazeal
Tera Contributor

You could add a client script that runs on change of


u_reassign_reason
that adds it to the work notes like:


g_form.setValue("work_notes", g_form.getValue("u_reassign_reason"));


Thank you Shane, one more question. Is there any way to put verbiage in front of the u_reassign_reason? Like "Incident Reassigned due to" + u_reassign_reason.


You could do

g_form.setValue("work_notes", "Incident reassigned due to " + g_form.getValue("u_reassign_reason"));

or

var workNotesVal = "Incident reassigned due to " + g_form.getValue("u_reassign_reason");
g_form.setValue("work_Notes",workNotesVal);


Great, works perfect!! Thank you both very much.