Cannot get a sys_user record

Yusuf5
Tera Expert

Hi Guys,

I am trying to get a sys_user record.

When I request the user record from admin it works.

When I try to do the same thing it doesn't get.

I am running GlideRecord from BusinessRule.

Any help is appreciated.

Regards

Yusuf

 

1 ACCEPTED SOLUTION

Snowdev3
Giga Expert

Hello,

 

Kindly, check the read access controls for the "sys_user" table. As per my understanding you are trying to say the user record is accessible from an admin account but not for any other role.

 Verify the below access control on user table and Check if required roles are added to these access control :

  • Read. none 
  • Read .* 

If this is appropriate , try to debug your business rule by adding log statements. 

You can also try to use impersonation script to debug in background script :

session.onlineImpersonate("skarke1990@gmail.com");
var gr = new GlideRecord('sys_user');
gr.get(usersysid);
gr.query();
if(gr.next()){
    gs.print('debug statement'+gr.email);
}
session.onlineUnimpersonate();

Debug : Impersonation script

Please mark helpful if its useful information for you 

Cheers !!

 

View solution in original post

14 REPLIES 14

Allen Andreas
Administrator
Administrator

Is the user record inactive?

There's a business rule that doesn't allow inactive users to come back in query so in your script you'd need to add something like:

gr.setWorkflow(false);

where gr is the variable for whatever you're using in your glide.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

I tried every option including this one.

Still no good.

If the user is inactive, as you've said in the other post below, then this will work...where are you placing that option?

You'd need to do this:

var user = new GlideRecord("sys_user");
user.setWorkflow(false);
if (user.get("user_sys_id")) {

      //If I try with a user with admin role it comes here otherwise it doesn't
      user.email = "new email address";
      user.update();
}

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

djohnson1
Mega Guru

Yusuf, 

    It is hard to answer this question without contextual examples. Can you provide the code snippet for review? If not, I suspect your issue is related to an incorrect GlideElementmethod in your Business Rule. Are you using getRefRecord() to return the referenced sys_user record?

 

Thanks, 

 

Derrick Johnson