gs.setProperty does not work for itil users

HugoFirst
Kilo Sage

I have a business rule with a setProperty command to change the value of a system property: glide.db.max_view_records.

When I update the associated record ( an incident ), the script runs correctly and the property is updated.  I am an admin user.  When a non-admin user with ITIL updates the record, the value of the property does NOT change.  No errors are logged that I can find.

 

The pertinent lines in the script:  ( shows the setProperty and a log command 😞

gs.setProperty("glide.db.max_view_records", "35000");
gs.log("OSSD:CWT Send OSSD Email:283, temp setting is " + temp_setting + ", glide.db.max_view_records set temporarily to " + gs.getProperty('glide.db.max_view_records') );

Any ideas?

1 ACCEPTED SOLUTION

Thanks and I'm very glad you figured it out. I've made a note as well. I appreciate it. I'll reciprocate with Helpful markings for you.

 

Solution is:

Create a ACL in the sys_properties table.

Place a condition on the ACL that the name mus be glide.db.max_view_records.

Save the ACL, and then, in the related list of Roles on the ACL, add an entry for itil.

Once this was done, the non-admin users, who have ITIL could run the script and the value of the properties would indeed change.


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

View solution in original post

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Looking in to this a bit more but found this:

"Script Actions execute as "system" (not system administrator) so your !gs.hasRole('itil') condition does not test against the user who triggered the event the Script action responds to."

The point of the above quote was just in case you were defining the condition by some "hasRole" definition. Since you haven't listed anything else about the BR or how you're specifying who can or can't use it.

Per: https://community.servicenow.com/community?id=community_question&sys_id=328447a9dbd8dbc01dcaf3231f96...

And I'm assuming your write roles have been defined on this specific sys_property?


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

HugoFirst
Kilo Sage

Hello Allen,

Thank you for the quick reply! I appreciate your help with this.

FWIW: The 2 lines of code reside in a length, complex business rule which runs when a user updates an incident record with a priority = 1.
There is no checking of roles in the BR and the 2 lines mentioned do execute as I can see the log message. IT may be interesting that the log message is attributed to the user logged in and updating the incident ( which is what I would expect )

WRT to write roles on the system property. I have run a couple of tests. First with the write roles set to null, and then with the write roles set to itil. Neither setting has an effect on the outcome.

Is there anything else I should consider?

HugoFirst
Kilo Sage

I have a fix this for and it is a result of Allen's last sentence about write roles.

 

The fix:

Create a ACL in the sys_properties table.

Place a condition on the ACL that the name mus be glide.db.max_view_records.

Save the ACL, and then, in the related list of Roles on the ACL, add an entry for itil.

Once I did this, the non-admin users, who have ITIL could run the script and the value of the properties would indeed change.

 

Allen A, if you reply to this comment with the solution I just mentioned, I'll mark it as the correct answer.

I'd like to give you credit for this.

Thanks again for your help!

 

Thanks and I'm very glad you figured it out. I've made a note as well. I appreciate it. I'll reciprocate with Helpful markings for you.

 

Solution is:

Create a ACL in the sys_properties table.

Place a condition on the ACL that the name mus be glide.db.max_view_records.

Save the ACL, and then, in the related list of Roles on the ACL, add an entry for itil.

Once this was done, the non-admin users, who have ITIL could run the script and the value of the properties would indeed change.


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