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

Arijit Gupta1
Giga Contributor

Hi Srini ,

 

You need to do two things :-

 

1. Go to the Dictionary record of the reference field and select Advance Reference Qualifier option there . Mention the qualifier as :-

javascript:new Dacgetassigngroup().getassgngrpDetail();

Do you need something from the current record to be sent to the Script Include also ? then you have to pass the current record value as well in the function.

2. In your Script Include you have to return something like 

return 'sys_idIN' + gp; 

where gp is either one group sys_id or comma separated sys_id's ( if you want to return multiple Groups in the reference qualifier )

David Arbour
Tera Guru

In your Script Include, simply concatenate the result of your Script Include to the end of your default reference qualifier. So make the return statement something like this. You may need to add a comma at the end of your default reference qualifier depending on the actual value of assignmentDetail. I'm assuming here it's simply a comma-separated list of Group names.

return 'cat_item=031d787fdb9fb410b5f9ee805b961907^approval=approved^assignment_group.nameINUK Data Centre Group,US Data Centre Group' + assignmentDetail;

shloke04
Kilo Patron

Hi,

Update your Reference Qualifier as below:

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

 

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

Srini19
Tera Contributor

Hi,

 

 

I need to use In statement for assignment group name since it will returns more than one value. so here is my ref qualifier but it returned no records

can you please tell what is wrong?

cat_item=031d787fdb9fb410b5f9ee805b961907^approval=approved^assignment_group.nameIN+javascript:newDacgetassigngroup().getassgngrpDetail();

 

Thanks

Srini