- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 03:18 AM
Hi All,
On the form level I have one of the field called "stockroom" and referring to alm_stockroom table.
And I have one field on the form level that is "Requested for" based on this requested for field I need to filter the stockroom field with stockroom record == active AND requestor is a member of the stockroom assignment group field this condition.
Please any one provide me the input,
Thanks in advance,
Atchamma D
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 04:13 AM - edited 10-25-2023 04:19 AM
Hi @Atchamma D
You can follow the below steps :
Step 1 : Create script include
Name : stockRoomUtils
var stockRoomUtils = Class.create();
stockRoomUtils.prototype = {
initialize: function() {
},
getStockroom : function(requested_for){
/*1. Declare the variables */
var result;
var groupArray =[];
/*2. get the groups which user is member of */
var grMem = new GlideRecord('sys_user_grmember');
grMem.addQuery('user',requested_for);
grMem.query();
while (grMem.next()){
/*3. get the groups in array */
groupArray.push(grMem.group.name);
}
/*4. set the result with query */
result = 'assignment_group.nameIN' + groupArray.toString(); //you can add your query here like for active 'active=true^assignment_group.nameIN' + groupArray.toString();
/*5. Return the result*/
return result;
},
type: 'stockRoomUtils'
};
Step 2 : on Stockroom variable write Advance reference qualifier
javascript: new stockRoomUtils().getStockroom(current.variables.requested_for); // use your variable name
Output :
In my case Abel tutor is member of "App Engine Admins" assignment group & this group is added to stockroom
Hope this helps....!!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 03:24 AM
Hi @Atchamma D
Is your requirement for catalog item or on Native UI form...??
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 03:30 AM
for catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 04:13 AM - edited 10-25-2023 04:19 AM
Hi @Atchamma D
You can follow the below steps :
Step 1 : Create script include
Name : stockRoomUtils
var stockRoomUtils = Class.create();
stockRoomUtils.prototype = {
initialize: function() {
},
getStockroom : function(requested_for){
/*1. Declare the variables */
var result;
var groupArray =[];
/*2. get the groups which user is member of */
var grMem = new GlideRecord('sys_user_grmember');
grMem.addQuery('user',requested_for);
grMem.query();
while (grMem.next()){
/*3. get the groups in array */
groupArray.push(grMem.group.name);
}
/*4. set the result with query */
result = 'assignment_group.nameIN' + groupArray.toString(); //you can add your query here like for active 'active=true^assignment_group.nameIN' + groupArray.toString();
/*5. Return the result*/
return result;
},
type: 'stockRoomUtils'
};
Step 2 : on Stockroom variable write Advance reference qualifier
javascript: new stockRoomUtils().getStockroom(current.variables.requested_for); // use your variable name
Output :
In my case Abel tutor is member of "App Engine Admins" assignment group & this group is added to stockroom
Hope this helps....!!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 04:24 AM
Thanks @Vishal Birajdar its working!!!