BR from Business Application table to Related Link table(cmdb_rel_person)

Al-jhon
Kilo Sage

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:

Aljhon_0-1721101200967.png


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!

1 ACCEPTED SOLUTION

Al-jhon
Kilo Sage

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.

View solution in original post

3 REPLIES 3

Satishkumar B
Giga Sage
Giga Sage

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. 

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:

var gr = new GlideRecord('cmdb_ci_business_app');
    gr.addQuery('sys_id', current.ci.getValue());
    gr.query();

Aljhon_0-1721108013813.png

 

Al-jhon
Kilo Sage

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.