Can't set 'Managed by group' field on a Win Server CI through the script

Vladimir6
Tera Expert

Dear all,

we are creating a Windows Server CI through the script in the workflow. The field Managed by group stays empty. Audit shows no changes in the field happening. Same variable returns the value nicely in another field (comments). The workflow has a pause tiemer in the beginning, so it runs as a System. Interestingly also, 1 time out of 7-10 the field will be filled. Any ideas?

 

//Create a Win Server
var win = new GlideRecord('cmdb_ci_win_server');
win.initialize();
win.support_group = 'fixed_sys_id'; //this works
win.managed_by_group = current.variables.managed_by_group; //the field stays empty
win.comments = "Managed by application group " + current.variables.managed_by_group.name; //this works
var winServId = win.insert();

 

 

1 ACCEPTED SOLUTION

We found the problem. Business rule "CSDM Data Sync on Reclassification" is wrongly clearing CI "managed_by_group" field, thinking that the class has been chancghed, even if the CI is created.

https://www.servicenow.com/community/itom-forum/business-rule-quot-csdm-data-sync-on-reclassificatio...

View solution in original post

13 REPLIES 13

It can still be a user (system) issue. I took the Timer out of the Workflow and run it as an Admin user. The field was filled nicely.

 

How can I get back to the real user after the Timer? This is a scoped app.

Vladimir6
Tera Expert

It looks like the field Managed by group ist not writable by the system user. What can be the technical solution here? As a reminder, this is a scoped application.

For example, calling from the workflow a global script where to use 

 

 

 

gs.getSession().impersonate(RITM.requested_by);

 

?

Brad Bowman
Kilo Patron
Kilo Patron

The internal System account is all-powerful with the admin role.  You need to fix/add whatever ACL or other restriction you have on this field/scope to allow admin access/override or you will be chasing down similar issues in the future. You can test this by manually or via fix script updating this field on a record while logged in as an account with the admin role.

We found the problem. Business rule "CSDM Data Sync on Reclassification" is wrongly clearing CI "managed_by_group" field, thinking that the class has been chancghed, even if the CI is created.

https://www.servicenow.com/community/itom-forum/business-rule-quot-csdm-data-sync-on-reclassificatio...