- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 08:36 PM
Hello all,
In sn_bcp_plan table i have BCP reviewer field.
If we add user or users to this field bc_reviewer role should be added automatically to that user.
How can we achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 09:11 PM
use log statements for current.contributors and groupID and check if they are returning expected values.
use hasNext() instead of next.
Please hit the thumb and Mark as correct if it helped!
Kind Regards,
Ravi Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 08:42 PM
Hello @Supriya P
Greetings!
You have to write update Business Rule on BCP Plan table
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var roleRecord = new GlideRecord('sys_user_has_role');
roleRecord.initialize();
roleRecord.user = gs.getUserID();
roleRecord.role = 'role sys_id here'; // give here the role sys_id
roleRecord.insert();
})(current, previous);
Please mark the answer as correct solution and helpful if helped.
Kind Regards,
Ravi chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 09:04 PM
Hello Ravi,
This script is not working, can we add user in a group instead of adding role to user. I have written below script but it is also not working.
var users2;
var groupID2;
users2= current.contributors;
groupID2 =gs.getProperty('sn_bcp.bcm_add_member_to_bcm_reviewer_group');
var memberRec = new GlideRecord('sys_user_grmember');
memberRec.addQuery('user',users2);
memberRec.addQuery('group', groupID2);
memberRec.query();
if(!memberRec.next()) {
memberRec.initialize();
memberRec.user = users2;
memberRec.group = groupID2;
memberRec.insert();
}
OR
var grpRecord = new GlideRecord('sys_user_grmember');
grpRecord.initialize();
grpRecord.user = gs.getUserID();
grpRecord.role = gs.getProperty('sn_bcp.bcm_add_member_to_bcm_reviewer_group'); // give here the role sys_id
grpRecord.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 09:11 PM
use log statements for current.contributors and groupID and check if they are returning expected values.
use hasNext() instead of next.
Please hit the thumb and Mark as correct if it helped!
Kind Regards,
Ravi Chandra