The CreatorCon Call for Content is officially open! Get started here.

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

Hey, sorry to bother you with this. The helpdesk just pointed out that the Technician Work Notes will disappear when you select the Assign Reason. Looks like it's taking out any information they've keyed into the Work Notes and updates the Work Notes with the "Assign Reason". Is there anyway to change this script to update the work notes with the assign reason but not take out the information they've keyed into the work notes.


zschneider
Kilo Expert

if you used the script above, you'd do this:

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


Thank you for the reply. If I use this script it does not populate the assign reason, it does keep the current work notes.


is your field name still u_reassign_reason?


It's actually u_assign_reason, but I did remember to change it in the script. I've tried adding this to the script below.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(g_form.isNewRecord()){
if (g_user.hasRole('FCRHelpDesk') && !g_user.hasRole('admin')){
if (g_form.getValue('assignment_group') != '8051349c0a0a3c1f005d2bbd78082b2d') {
g_form.setDisplay('u_assign_reason',true);
g_form.setMandatory('u_assign_reason',true);
//alert("Assign reason is mandatory");
}
else {
g_form.setDisplay('u_assign_reason',false);
g_form.setMandatory('u_assign_reason', false);

}
}
}
}

Also, tried it in this script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}

g_form.setValue("work_notes",+ "Incident assigned due to" + g_form.getValue("u_assign_reason"));


}