- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 08:42 PM
Hello everyone,
I have a requirements to prevent any IT user, except "system owner", "IT owner" or member of support group to create/update/delete record from the related table "cmdb_rel_person" in CMDB CI Business Application.
Here's my BEFORE BR:
This is not working and i don't know why is it the ci sysid in cmdb_rel_person is equal from the current.getUniqueValue which is the sysid of the Business Application?
Can anyone give idea/s what is wrong with my codes?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 06:32 PM
I already figured this out already.
The business rule table is cmdb_rel_person and I used GlideRecord on cmbd_ci_business_app table to query.
I just added !gs.isInteractive() on the condition to avoid BR running in the flow designer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 08:54 PM
Hi @Al-jhon
Refer this:
(function executeRule(current, previous /*null when async*/) {
// Get the current user ID
var getUserID = gs.getUserID();
// Query the cmdb_rel_person table for the related CI
var gr = new GlideRecord('cmdb_rel_person');
gr.addQuery('ci', current.getUniqueValue());
gr.query();
while (gr.next()) {
// Get the system owner, IT application owner, and support group
var sysOwner = gr.ci.owned_by.getValue();
var itAppOwner = gr.ci.it_application_owner.getValue();
var supportGroup = gr.ci.support_group.getValue();
// Check if the current user is the system owner, IT application owner, or a member of the support group
var isOwner = (getUserID == sysOwner || getUserID == itAppOwner || gs.getUser().isMemberOf(supportGroup));
if (isOwner) {
gs.addInfoMessage("User(s) has been added/deleted");
} else {
gs.addErrorMessage("You do not have access to add/remove user!!");
current.setAbortAction(true);
return;
}
}
})(current, previous);
……………………………………………………………………………………………………
Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 10:33 PM - edited 07-15-2024 10:37 PM
Hello @Satishkumar B , thank you for your response, but i think it is the same logic as mine.
My problem is i think there is no value when i'm using current.getUniqueValue().
This should be the SysID of the business application where i compared in the ci field of cmdb_rel_person table.
But when i set the BR Table to cmdb_rel_person then change the gliderecord to cmdb_ci_business_app it give's value:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 06:32 PM
I already figured this out already.
The business rule table is cmdb_rel_person and I used GlideRecord on cmbd_ci_business_app table to query.
I just added !gs.isInteractive() on the condition to avoid BR running in the flow designer.