- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 12:05 PM
I want to restrict catalog tasks for certain catalog item to only if it matches the company variable on the record. I am trying to write a before query BR where I set the item in Filter condition. I see some java script errors after I add this.
I am not able to access the name or variables using the following.
var item_name = current.request_item.cat_item.name;
var comp = current.variables.company.toString();
Ant ideas on how to get this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 02:18 PM
OK, so not terribly crazy on the before Query script, but still dangerous as no one will see every Catalog Task for these items now. You can run this BR with no Filter Conditions or Condition:
(function executeRule(current, previous /*null when async*/) {
var tskArr = [];
var tskGR = new GlideRecord('sc_task');
tskGR.query();
while (tskGR.next()) {
//push every Catalog Task to an array, unless it belongs to Catalog Item 'A'
if (tskGR.request_item.cat_item.name != 'A'){
tskArr.push(tskGR.sys_id.toString());
//only push this Catalog Item's tasks if the 'company' variable value is the same as the current user's
} else if (tskGR.variables.company == gs.getUser().getRecord().getValue('company')) {
tskArr.push(tskGR.sys_id.toString());
}
}
current.addQuery('sys_id', 'IN', tskArr.join(','));
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 12:46 PM
if you want to see the name you need the following.
current.request_item.cat_item.getDisplayValue()
current.variables.company.getDisplayValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 12:49 PM
I tried that but no luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 12:59 PM
Can you give us all the code and explain more what you are trying to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 01:06 PM
I have a Query business rule on sc_task. I am trying to restrict the sc_tasks related to catalog item A to only users in the same company.
