- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2016 03:56 AM
Hi all - I've been trying to do this for over an hour now with my very limited scripting knowledge but it's frustrated me and still isn't working.
I am trying to add a user to the Watch List of an Incident if the customer's company is a particular value. I thought it was as simple as this but it isn't working (onChange Client Script):
var cust = g_form.getReference('caller_id');
if (cust.company = 'XYZ Company') {
g_form.setValue('watch_list', 'Anthony User');
}
When this didn't work I tried something with 'new GlideRecord' but that's me way out of my depth! Can anyone help wit this please?
Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2016 04:10 AM
Hi Wayne,
Why did you choose onChange Client Script? Could you please elaborate what are you trying to achieve here?
I think it will be better if you implement this operation using 'Before Insert & Update' Business Rule.
You can try something like this
if(current.caller_d.company==<Mention Company Name here>){
current.watch_list=current.caller_id;
}
Thanks
Abhinandan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2016 04:10 AM
Hi Wayne,
Why did you choose onChange Client Script? Could you please elaborate what are you trying to achieve here?
I think it will be better if you implement this operation using 'Before Insert & Update' Business Rule.
You can try something like this
if(current.caller_d.company==<Mention Company Name here>){
current.watch_list=current.caller_id;
}
Thanks
Abhinandan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2016 06:03 AM
Thanks Abhinandan, this is a much simpler solution. The idea of using a Client Script was to give the call logger the option to remove it but I don't think that's a requirement anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2016 04:15 AM
Hi Wayne,
You're on the right track with your script however you'll need to provide the reference to the user you want to add to the watch list. So if you're doing this client side, you'd need to lookup the sys_id for Anthony User
As a suggestion, you could make this generic and add a default watch list field on your company table. You could then use the code below to always copy the watch list across
var strWatchList = company.u_default_watch_list.toString();
if (strWatchList != '') {
g_form.setValue('watch_list', strWatchList);
}
Kind regards,
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2016 04:28 AM
Hello Wayne,
Instead of doing onChange Script. Try to do onSubmit script.
Sample.
function onSubmit(){
var cust = g_form.getReference('u_requester');
alert(cust.company);
if (cust.company = 'XYZ Company') {
alert("Inside IF");
g_form.setValue('watch_list', 'Wayne Richmond');
}
}
FYI:- You can directly add name of your user it will work(if you spell it correctly). But,Best practice is to use "sys_id" instead of name whenever you are using reference.
Regards,
Vaibhav
P.S:- Mark this answer as helpful or Correct accordingly.