- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 08:59 PM
I have a catalog item with variable "Change Request" which is a refrence field to change request table and another variable "SP Email" .I have to fetch the email ID of SP change coordinator from change request table .
I am using script include and onChange client script for this but not able to fetch any values.
onChange Client Script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 09:13 PM
Hi @Shalika,
I agree with @Tony Chatfield1, In your script include, line
var ciID = this.getParameter('sysparm_name');
should be
var ciID = this.getParameter('sysparm_ci');
Note -
It should be same parameter name used in client scritps Glide ajax call.
ga.addParam('sysparm_ci', g_form.getValue('change_request_id'));
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 09:05 PM
Hi, what are the results of your debugging?
Is the serverside function called and are you passing in the correct parameters?
Is the correct value returned to the client script?
screenshots are not an appropriate method to share code, and you should use plain text.
But looking at you images I don't think you are referencing the correct parameter inside getEmail() - IE you are referencing sysparm_name and I think you might want sysparm_ci
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 09:08 PM
Client Script -
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setValue('sp_change_coordinator_email', '');
}
var ga = new GlideAjax('emailSp');
ga.addParam('sysparm_name', 'getEmail');
ga.addParam('sysparm_ci', g_form.getValue('change_request_id'));
ga.getXML(doPopulate);
}
function doPopulate(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('sp_change_coordinator_email', answer);
}
Script Include -
var emailSp = Class.create();
emailSp.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getEmail: function() {
var retVal = '';
var ciID = this.getParameter('sysparm_name');
var ci = new GlideRecord('change_request');
// If Business Service found, return its product code
if (ci.get(ciID)) {
if (ci.assigned_to != '') {
retVal = ci.assigned_to.email;
}
}
return retVal;
}
});
What should I use instead of sysparm_ci?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 09:11 PM - edited ‎11-09-2022 09:13 PM
Line no. 6 in your script include is not correct, it should be:
var ciID = this.getParameter('sysparm_ci') instead of 'sysparm_name' because you are passing sys_id of change request in 'sysparm_ci' from your client script.
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 09:12 PM
hi Shalika,
your script include - code line 6 is wrong parm name
hope this help!