- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 08:59 AM
Hi ServiceNow community!
I have set up a script action to modify the system property "collaboration.frameset", but am running into an issue where the system property is not updating upon logging in with a test user who has no roles. Can someone help me debug this?
have used this same method previously to modify a user preference and was hoping to do the same to scriptomagically disable the property with a role-based condition.
Thanks for taking a look at this for me.
Below is my script action...
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 10:36 AM
Could it be that the ACL's are restricting access to the system properties for the user, therefore they cannot update the value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 09:03 AM
Also, I just built a quick fix script to test this and this returns "true" then "false". Is it possible to adapt this for use in my script action?
var gr = new GlideRecord('sys_properties');
gr.addActiveQuery();
gr.addQuery('name','collaboration.frameset');
gr.query();
if (gr.next()) {
var user = new GlideRecord('sys_user_has_role');
user.addActiveQuery();
user.addQuery('user_name','Test.User');
gs.print('System Property: ' + gr.name + ' has a value of ' + gr.value);
if (user.gs.hasRoles != 'itil') {
gr.value = "false";
}
gs.print('System Property: ' + gr.name + ' has a value of ' + gr.value);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 10:23 AM
When updating a value in any table in SN you need to run the update() method once you query for the correct record. So,
var gr = new GlideRecord('sys_properties');
gr.addActiveQuery();
gr.addQuery('name','collaboration.frameset');
gr.query();
if (gr.next()) {
gr.value = false;
//gr.setWorkflow(false); //this will prevent business rules from running, if required
gr.update();
}
Remember almost everything in SN is a table. Always be aware of onUpdate business rules that may run because of this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 10:31 AM
Thanks Nick. I combined our scripts and when I log in as a test user who has no roles I still see the Connect and presence indicators, which tells me the script action didn't work... other thoughts?
var gr = new GlideRecord('sys_properties');
gr.addActiveQuery();
gr.addQuery('name','collaboration.frameset');
gr.query();
if (gr.next()) {
var user = new GlideRecord('sys_user_has_role');
user.addActiveQuery();
user.addQuery('user_name',gs.getUser());
if (user.gs.hasRoles != 'itil') {
gr.value = "false";
gr.setWorkflow(false); //this will prevent business rules from running, if required
gr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 10:36 AM
Could it be that the ACL's are restricting access to the system properties for the user, therefore they cannot update the value?