Business rules for dependent variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 04:53 AM
I am having 3 variables, all are reference fields on a custom table.
Var1 is in custom table and is a reference field, and Var 1 type in table is reference to another master table.
Var2 is in custom table and is a reference field, and Var 2 type in table is reference to another master table.
Var3 is in custom table and is a reference field, and Var 3 type in table is reference to another master table.
var 1 is having dupilicate entries, and var2 has to populate based on var1
and Var3 has to populate based on the Var2 and Var 1.
I have written the code like this,
Var 1 and Var 2 are working
Var 3 is not working.
Var1 is BusinessGroup
Var2 is BusinessUnits
Var3 is world area. (this part is not working)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 05:05 AM
I think you are not passing the businessgroup to your last one. And are you sure the first part is working, or didn't you copy/paste the code? There's a type in the return for 'choices'.
Can you check if this works:
// BusinessGroup function to fetch unique Business Groups
BusinessGroup : function() {
gs.log("Fetching Business Groups");
var choices = [];
var gr = new GlideAggregate('u_ehsvelocities');
gr.groupBy('u_business_group');
gr.query();
while (gr.next()) {
gs.log("Business Group: " + gr.u_business_group);
choices.push(gr.getValue('u_business_group').toString());
}
return 'sys_idIN' + choices.join(',');
},
// BusinessUnits function to fetch based on BusinessGroup
BusinessUnits : function(BusinessGroup) {
gs.log("Fetching Business Units for Business Group: " + BusinessGroup);
var unitchoices = [];
var gr = new GlideRecord('u_ehsvelocities');
gr.addQuery('u_business_group', BusinessGroup);
gr.query();
while (gr.next()) {
gs.log("Business Unit: " + gr.u_business_unit);
unitchoices.push(gr.getValue('u_business_unit').toString());
}
return 'sys_idIN' + unitchoices.join(',');
},
// WorldArea function to fetch based on both BusinessGroup and BusinessUnits
WorldArea : function(BusinessGroup, BusinessUnits) {
gs.log("Fetching World Areas for Business Group: " + BusinessGroup + " and Business Units: " + BusinessUnits);
var worldareas = [];
var gr = new GlideRecord('u_ehsvelocities');
gr.addQuery('u_business_group', BusinessGroup);
gr.addQuery('u_business_unit', BusinessUnits);
gr.query();
while (gr.next()) {
gs.log("World Area: " + gr.u_world_area);
worldareas.push(gr.getValue('u_world_area').toString());
}
return 'sys_idIN' + worldareas.join(',');
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2024 06:11 AM
Hi Mark,
yes first part is working .
I will try the solution provided by you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2024 07:46 AM
in the variable section, i have passed like this.
this is not working.
How to give the reference qual here?
thankyou for helping,