How to combine script include with existing reference qualifier

Srini19
Tera Contributor

Hi Expert,

user case is need to popup the Request number based on current logged in user's assignment group which are associated with the RITM

I need to combine the script include with the existing reference qualifier. Please let me know how I can achieve this.

 

Existing reference qualifier on Request Number reference field:

cat_item=031d787fdb9fb410b5f9ee805b961907^approval=approved^assignment_group.nameINUK Data Centre Group,US Data Centre Group

Just hard coded the assignment group here.  just want to combine the existing reference qualifier with script include which will return the assignment groups

Below is the script include(which is working fine)

 

var Dacgetassigngroup = Class.create();
Dacgetassigngroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getassgngrpDetail: function() {
var groups = '';
var ritmDetail='';
var assginmentDetail= '';
var groupName ='';
var currentuserid = this.getParameter('user_select');
gs.addInfoMessage("current user is ---" + currentuserid);
var grps = new GlideRecord('sys_user_grmember');
grps.addQuery('user', currentuserid);
grps.query();
while (grps.next()) {
//gs.addInfoMessage("I am in grps next");
groups += (',' + grps.group);

var grdc = new GlideRecord('cmdb_ci_datacenter');
grdc.addQuery('support_group.name', grps.group.name);
//gs.addInfoMessage("users group name is"+grps.group.name);
grdc.query();

while (grdc.next()) {
// gs.addInfoMessage(" list of Group name for user is" + grdc.support_group.name);
assginmentDetail += (',' + grdc.support_group.name);
}
}
//gs.addInfoMessage("Final list of assignment group is" + assginmentDetail);

if (assginmentDetail != "")
{
assginmentDetail = assginmentDetail.substring(1,assginmentDetail.length());
gs.addInfoMessage("Final list of assignment group is" + assginmentDetail);

}

return assginmentDetail;
},
type: 'Dacgetassigngroup'
});

 

Thanks

Srini

5 REPLIES 5

Hi,

I will suggest to modify your Script Include and return Assignment Group as a comma separated value of Assignment Group Sys ID something similar to this in your Script Include:

return 'sys_idIN' + arr.toString();

Once you have done this, you can update your Reference Qualifier as below:

cat_item=031d787fdb9fb410b5f9ee805b961907^approval=approved^ + javascript: new Dacgetassigngroup().getassgngrpDetail();

Can you share more details on what are you trying to do within your Script Include, there can be a better way to design your code I believe.

Please share on what are you trying to achieve in your Script Include?

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke