Business rule and ACL are effeting the portal.

Vurukonda Sai 1
Tera Contributor
loged in user belongs to HR_Marelli_CN group user can able to view the HR case from List view and China user region user can't see the EMEA region user HR cases. this the requiremet i have wrote the BR for below code. 
but it is efeting in HR Portal end user end. I have attached the screenshot.

Business rule:

(
function executeRule(current, previous /*null when async*/ ) {

    var userRegion = gs.getUser().getRecord().getValue('u_region'); // Assume you have a method to get


    var query = '';

    var gr = new GlideRecord('sys_user_grmember');
    gr.addEncodedQuery('group=fd665c24c36e62507ee9da4bb001310e^user=' + gs.getUserID());
    gr.query();
    if (gr.next()) {
        query = '';

    } else if (userRegion == 'CHINA') {

        query = 'u_region!=EMEA';

    }
    current.addEncodedQuery(query);


})(current, previous);


ACL for HR_Marelli groups user for HR case only read access we restric the write and update.


 
answer = false;

//if (gs.getUser().isMemberOf('HR_Marelli_CN') && current.isNewRecord())
if (gs.getUser().isMemberOf('HR_Marelli_CN') && current.isNewRecord() || gs.getUser())

    answer = true;
 
Kinldy help me on this issue. but urgent.
1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

I'm not sure I understand your ACL if statement. It seems incomplete after the or. You just have gs.getUser() but by itself that would not do anything. So they ACL is probably returning false. I think after the or you should just have current.isNewRecord() so it would look something like this.

 

if ((gs.getUser().isMemberOf('HR_Marelli_CN') && current.isNewRecord()) || current.isNewRecord())

 

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Vurukonda Sai 1 

then ensure this business rule runs only for agents and not for end users.

Try checking some role in BR condition

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I need end user end also. Kinldy help me on this

Brian Lancaster
Tera Sage

I'm not sure I understand your ACL if statement. It seems incomplete after the or. You just have gs.getUser() but by itself that would not do anything. So they ACL is probably returning false. I think after the or you should just have current.isNewRecord() so it would look something like this.

 

if ((gs.getUser().isMemberOf('HR_Marelli_CN') && current.isNewRecord()) || current.isNewRecord())

 

if (gs.getUser().isMemberOf('HR_Marelli_CN') && current.isNewRecord() || current.isNewRecord())
Thank you for this code ACL working.