- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 11:43 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var Emp = new GlideRecord('sc_req_item');
Emp.addQuery('sys_id', newValue);
Emp.query();
while(Emp.next()) {
g_form.setValue('u_first_name', Emp.variables.u_first_name);
}
}
i used this code but this gives me undefined in my coloumn
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 12:09 PM
Hi Manohar,
Please check this link https://community.servicenow.com/thread/219073?q=use%20script%20include%20value%20in%20client%20scri...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 12:24 PM
Hi Manohar,
when you open a new catalog form, it doesn't initially create a Request or Request Item. It only creates these when you submits the catalog form and in that case all the variables you filled in the catalog form gets linked to the Request Item created.
So if user want to use the variables of a Rejected Request Item, He/she will have to provide the reference of that RITM and then you can use GlideAJAX along with Script include to fetch the variable data from that RITM. Please use GlideAjax - ServiceNow Wiki to get more information on how to use GlideAjax and Script include.
Hope it would help.
Regards,
Ishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 12:09 PM
Hi Manohar,
Please check this link https://community.servicenow.com/thread/219073?q=use%20script%20include%20value%20in%20client%20scri...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 12:17 PM
Try this out.
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == ' ') {
return;
}
var ga = new GlideAjax('GetRequestedItemVariablesAjaxJSON');
ga.addParam('sysparm_name','getUsersValues');
ga.addParam('sysparm_cat_id',g_form.getValue('newValue'));
ga.getXML(ajaxResponse);
function ajaxResponse(response){
var answer = JSON.parse(response.responseXML.documentElement.getAttribute('answer'));
for (var i = 0; i < answer.length; i++) {
g_form.setValue('u_first_name',answer[i].name);
}
}
script include:
Name: getnamevalue
var getnamevalueAjaxJSON = Class.create();
getnamevalueAjaxJSON.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUsersValues: function() {
var cat_id = this.getParameter('sysparm_cat_id');
var gr = new GlideRecord('sc_req_item');
var answer = [];
gr.addQuery('sys_id',cat_id);
gr.query();
if(gr.next()){
answer.push({
'name': gr.variables.u_first_name +'',
});
}
return new JSON().encode(answer);
},
type: 'getnamevalueAjaxJSON'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 01:20 PM
Thank you guys for the help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2016 03:18 PM
What was your end solution to this? Thanks.