Write script include with advanced reference qualifier to return multiple values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 11:18 PM
I have a form, by using one field from the form (name), I have to fetch the request number, requested item, and state is approved, from the task table (request raised by the same user) to populate values to other form values(request number, requested item, and state is approved)by using script include using reference qualifier.
I am a beginner in service now, please help me with the code.
My code:
Script includes:
var Approved_MPS = Class.create();
Approved_MPS.prototype = Object.extendsObject(global.AbstractAjaxProcessor,{
getStoreIDs: function(a){
gs.log("Script Include called ");
var a= a;
gp = [];
if(!a)
return;
if(a){
var gr = new GlideRecord('task');
gr.addQuery('requested_for',a);
gr.query();
while(gr.next()) {
gp.push(gr.sys_id.toString());
}
gs.info('Im here');
return 'sys_idIN' + gp;
}
},
type: 'Approved_MPS'
};
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2022 10:35 AM
Hi sujithra,
I'm not sure if this will achieve your need. With this you'll get all the task related to the query you are applying on task table but only in one reference field (this field, also must be referenced to task), multiple fields won't be filled with this automatically.
However, I've checked you code, try this as below:
var Approved_MPS = Class.create();
Approved_MPS.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getStoreIDs: function(a) {
gs.log("Script Include called ");
gp = [];
if (a == '') {
return;
}else{
var grTask = new GlideRecord('task');
grTask.addQuery('requested_for', a);
gr.query();
while (gr.next()) {
gp.push(gr.sys_id.toString());
}
gs.log('Im here');
return 'sys_idIN' + gp.join();
}
},
type: 'Approved_MPS'
});
If it was helpful, please give positive feedback.
Thanks,
☆ Community Rising Star 22, 23 & 24 ☆