- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 02:42 AM
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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 02:48 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 03:23 AM
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
Script include:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 02:56 AM
@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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 03:01 AM
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;
},
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 03:01 AM
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