- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 01:07 AM - edited 10-14-2022 01:28 AM
Hi all ,
use case - write a Onchange client script and script include also to Automatic add caller manager into watchlist when i change caller field in the incident form .
please help me to do this use case
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 01:33 AM
Hello,
Please create a script include with name Getemail as below:-
Write the below code in script include:-
var Getemail = Class.create();
Getemail.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getemail: function() {
var email=this.getParameter('sysparm_email');
var gr=new GlideRecord('sys_user');
gr.addQuery('sys_id',email);
gr.query();
if(gr.next());
{
return gr.manager;
}
},
type: 'Getemail'
});
Then use the below code in onchange client script:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var email=g_form.getValue('email');
var ga = new GlideAjax("Getemail");
ga.addParam('sysparm_name', 'getemail');
ga.addParam('sysparm_email',newValue);
ga.getXML(callback);
function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('watch_list', answer);
}
}
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 06:46 AM
Please send me the screenshot of the caller field and also the user you are trying to test send me the manger field is populated for that on user table screenshot as well.
Also did you try the putting alert('answer'+answer); in the code cline script below answer varibale what vlaue did you get for answer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 06:50 AM - edited 10-14-2022 06:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 06:56 AM
Can you put alert('answer'+answer); in your script and let me know what answer was printed or is it coming blank?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 06:58 AM
sir i don't get any alert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 07:00 AM
Hello
why is the user locked out uncheck the locked out field it will work
Please mark my answer as correct based on Impact.