Onchange client script triggerd on Load

Tomer
Kilo Expert

Hello experts,

i'm trying reach this functionality: when supporter turns ticket to resolve/pending, assign it to him automatically by Onchange client script. 

We need this as a client script and not BR cause we want the supporter will see this change immediately. 

Here is my piece of code:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue=="Resolved" || newValue=="Pending"){
var supporter = g_user.userID.toString();
g_form.setValue('assigned_to',supporter);
}

This is working, but makes a weird bug - works on load and changes the assignee (without saving) when he is just looking at the ticket - when the status field not change

Thank you for any kind of help,

Tomer.

find_real_file.png

5 REPLIES 5

Rahul Kumar17
Tera Guru

hi,

every thing is fine but u pass the value of state Resolved-7,Pending-3

 

first check the value of Resolved and Pending state then try this code:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
if (newValue==7|| newValue==3){
var supporter = g_user.userID.toString();
g_form.setValue('assigned_to',supporter); 
}

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar