The CreatorCon Call for Content is officially open! Get started here.

Call a property in script include which is called in Reference Qualifier

Nandini DM
Tera Contributor

Hi ,

I have a Script Include which sets the "group" field based on "type" field, however I am not supposed to use sys_id in script include and created system property for each sys_id which needs to be called in script include 

 

Below is the code which is working fine when sys_id is directly added to the script , here my question is how to add system property in place of sys_id in the below code?

 

var a = gs.getProperty(populate.group.based.on.type.finance);

 u_getGroupRefQual: function() {
        var filter = '';
        if (current.variables.do_you_need_access_to_finance_hr_or_it_applications.getDisplayValue() == 'Finance') {
            filter = 'active=true^type=747c67191b59ac500b457662164bcba4';
        }
        return filter;
    },
 
Please help me!
Thank you in advance!
1 ACCEPTED SOLUTION

M Ismail
Tera Guru

Hi @Nandini DM,

try this code 

u_getGroupRefQual: function() {
    var filter = '';
    var financeSysId = gs.getProperty('populate.group.based.on.type.finance');

    if (current.variables.do_you_need_access_to_finance_hr_or_it_applications.getDisplayValue() == 'Finance') {
        filter = 'active=true^type=' + financeSysId;
    }
    return filter;
},

Please hit helpfult and accept this as a solution if it solved your problem.
Thank you!

View solution in original post

13 REPLIES 13

Hi @Nandini DM ,

 

you can do it through reference qualifier and script include,

 

Type field make it reference to "sys_user_group_type"

Group field to "sys_user_group"

 

In group field reference qualifier call the script include,

 

javascript: new getTypeDeatil().getType(current.variables.group_type) // here group_type is backend name of Type field

 

swathisarang98_0-1710238887461.png

Script include:

swathisarang98_1-1710238914066.png

 

var getTypeDeatil = Class.create();
getTypeDeatil.prototype = {
    initialize: function() {
    },

	getType: function (type){

		var gr = new GlideRecord('sys_user_group');
		gr.addQuery('type',type);
		gr.addActiveQuery();
		gr.query();
		var arr =[];
		while(gr.next()){
			arr.push(gr.sys_id.toString());
		}
		return "sys_idIN" + arr ;


	},

    type: 'getTypeDeatil'
};

 

 

I just tried in pdi its working 😊. let me know if it doesn't work for you

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

Nandini DM
Tera Contributor

@Harish KM 
No , we donn't have multiple sys_id's , sys_id referring to Type table 
Below is the script which I tried and it is not working 

var a = gs.getProperty(populate.group.based.on.type.finance);

 u_getGroupRefQual: function() {
        var filter = '';
        if (current.variables.do_you_need_access_to_finance_hr_or_it_applications.getDisplayValue() == 'Finance') {
            filter = 'active=true^type=a';
        }
        return filter;
    },
 

Hi @Nandini DM corrected the code, refer bold lines

var a = gs.getProperty('populate.group.based.on.type.finance');
u_getGroupRefQual: function() {
var filter = '';
if (current.variables.do_you_need_access_to_finance_hr_or_it_applications.getDisplayValue() == 'Finance') {
filter = 'active=true^type='+a;
}
return filter;
},

Regards
Harish

Why not directly query the 'type' table? You are now creating properties to get a record you can directly query to.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark