Onload client script is not working in reload page

siva44
Tera Contributor

I have created one onload client script for read only of impact and urgency fields based on role condition but it is not working in reload page like when that role assign the user then it is not working after user again log in then it is working 

If anyone known that troubleshoot please let me known

Onload client script :

function onLoad() {

//Type appropriate comment here, and begin script below

if(g_user.hasRoleExactly('priority manager')){

 setTimeout(function() {g_form.setReadonly('urgency', false ); }, 0); setTimeout(function() {g_form.setReadonly('impact', false ); }, 0); }

 

}else{ setTimeout(function() {g_form.setReadonly('urgency', true); }, 0); setTimeout(function() {g_form.setReadonly('impact', true); }, 0); }

}

1 ACCEPTED SOLUTION

Hi,

That may be tricky since add/remove role will perhaps not be a related activity. Easiest is perhaps to combine it with a info message "If you recently were assigned the role, please logout and try again".

 

Regards,
Niklas

View solution in original post

3 REPLIES 3

Niklas Peterson
Mega Sage
Mega Sage

Hi,

This is expected behaviour. Assigning a role to a user requires a new session before the user has that role.

 

"If the user is logged in when you update their roles, the user may need to log out and back in again if they are unable to access records allowed by the new role."

 

https://docs.servicenow.com/en-US/bundle/vancouver-platform-administration/page/administer/users-and...

 

Regards

Niklas

 

 

Okay how to configured in reload page if any another methods is there for that

Hi,

That may be tricky since add/remove role will perhaps not be a related activity. Easiest is perhaps to combine it with a info message "If you recently were assigned the role, please logout and try again".

 

Regards,
Niklas