- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 03:24 AM
Hi Folks,
I am trying to update inactive user's manager to the author of knowledge article. When user moves to inactive his/her manager should be updated to his owned articles. Below is the BR with condition when active changes to false.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 03:43 AM
I tried in my PDI and below BR is working for me
Advanced: true
When: async
Insert: true
update: true
Filter conditions: Active changes to false
Advanced:
(function executeRule(current, previous /*null when async*/ ) {
var Mngr = current.getValue('manager');
var kbUsr = new GlideRecord('kb_knowledge');
kbUsr.addEncodedQuery("active=true^author=" + current.getValue("sys_id"));
kbUsr.query();
while (kbUsr.next()) {
// gs.info("KB", kbUsr.number);
//Mgr = kbUsr.author.manager.toString();
kbUsr.author = Mngr;
kbUsr.setWorkflow(false);
kbUsr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 03:43 AM
I tried in my PDI and below BR is working for me
Advanced: true
When: async
Insert: true
update: true
Filter conditions: Active changes to false
Advanced:
(function executeRule(current, previous /*null when async*/ ) {
var Mngr = current.getValue('manager');
var kbUsr = new GlideRecord('kb_knowledge');
kbUsr.addEncodedQuery("active=true^author=" + current.getValue("sys_id"));
kbUsr.query();
while (kbUsr.next()) {
// gs.info("KB", kbUsr.number);
//Mgr = kbUsr.author.manager.toString();
kbUsr.author = Mngr;
kbUsr.setWorkflow(false);
kbUsr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 10:28 AM
You might want to add a check in there to make sure there is a value in the "manager" field. Otherwise, you would be clearing out that field.