- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 12:09 PM - edited 07-07-2024 12:11 PM
Hi Team,
Am trying with below client script and server side script to get the alert message on form for the selected caller.
Client script
Script include
But am not getting null, can someone help me out to find the error
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 12:36 PM
Hi @Roshini ,
All code is correct, just a mistype is there which is causing the issue.
In Catalog Client Script, Instead of:
alertDetails.addParam('sysparam_name','userDetails');
alertDetails.addParam('sysparam_userid', newValue);
It will be:
alertDetails.addParam('sysparm_name','userDetails');
alertDetails.addParam('sysparm_userid', newValue);
In the Script include, Instead of:
var id = this.getParameter('sysparam_userid');
It will be:
var id = this.getParameter('sysparm_userid');
The rectified final code will be:
Script Include:
var UserLearning = Class.create();
UserLearning.prototype = Object.extendsObject(AbstractAjaxProcessor, {
userDetails: function() {
var id = this.getParameter('sysparm_userid');
var gr = new GlideRecord('sys_user');
if (gr.get(id)) {
var userObj = {
"email": gr.getValue("email"),
};
return JSON.stringify(userObj);
}
},
type: 'UserLearning'
});
Catalog Client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var alertDetails = new GlideAjax('UserLearning');
alertDetails.addParam('sysparm_name', 'userDetails');
alertDetails.addParam('sysparm_userid', newValue);
alertDetails.getXMLAnswer(details);
function details(detail) {
if (detail) {
var a = JSON.parse(detail);
alert("email is " + a.email);
}
}
}
The output is:
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 12:39 PM
Thanks a lot, it was typo error