Onchange client script triggerd on Load
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 08:32 AM
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.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2019 05:43 AM
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);
}
}
Thanks,
Rahul Kumar