ACLs bug

arturito
Tera Contributor

Hi 
I am experiencing a weird issue with ACLs impersonating users. I have a table, access to which requires a "user" role. This role is assigned automatically to a customer after he fills the form and submits it with before business rule. The role is assigned to user, I can even see the info message, but trying to reach a table page right after shows the error "Security constraints prevent access to requested page". When I finish an impersonation and start it once again, everything works as expected. Here is code of business rule: 

 

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

    var pumpersTb = 'x_1124584_mypump_pumpers';
    var groupTb = 'sys_user_grmember';
	var endUserGroup = "60c9afdf47e94210208d1a2f316d435c"
    var url = "https://dev192434.service-now.com/now/nav/ui/classic/params/target///x_1124584_mypump_pump_progress.do%3Fsys_id%3D-1%26sysparm_stack%3Dx_1124584_mypump_pump_progress_list.do";

    //checks if user record already exists in table
    var pumpGr = new GlideRecord(pumpersTb);
    if (pumpGr.get('user', current.user)) {
        current.setAbortAction(true);
        return gs.addErrorMessage('Current user is already part of MyPump community');
    }
	// adds user a group for access
    var addGroupGr = new GlideRecord(groupTb);
    addGroupGr.initialize();
    addGroupGr.user = current.user.sys_id;
    addGroupGr.group = endUserGroup;
    addGroupGr.insert();
	return gs.setRedirect(url);

})(current, previous);

 

 

1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hi @arturito,

 

The new role takes effect after starting a new session, meaning the user needs to log out and log back in.

 

Cheers

View solution in original post

6 REPLIES 6

Thank you!

Basheer
Mega Sage

Hi @arturito ,

Log out and login and then impersonate, it should work.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.