Sync user/group/roles data from PROD to lower instances

Tejal Patil1
Tera Expert

Hello Everyone,

 

I need to synchronize user, group, and role data from our Production instance to our Dev and Test instances. Specifically, when a user, group, or role record is created in Production, it should also be created in the Dev and Test instances.

I attempted to achieve this using REST integration; however, this approach is causing issues with sysid mismatches. When a record is created in Production and then replicated to Development/Test instances using the REST POST method, it is assigned a different sysid in those instances. I've learned that any integration or transform map may lead to sysid conflicts, so this approach isn't feasible.

I am aware that the IDR (Instance Data Replication) plugin can replicate data but it is paid and is not recommended for system tables such as user, group, and role records. Since we need to automate this process, a manual import/export approach is not suitable.

 

Could anyone suggest an alternative method to automate this synchronization?

 

 

Thank you.

 

1 ACCEPTED SOLUTION

Tejal Patil1
Tera Expert

This requirement can be fulfilled using the paid ServiceNow Remote Instance Spoke. Once the proper connection is established, records can be created in lower instances. We encountered a sys_id issue, which we addressed by making necessary customizations in the transform map.

View solution in original post

15 REPLIES 15

I have created a After insert business rule on user table that hits the rest message. Within BR I am sending the parameters as mentioned below
 
 var body = {
        "user_name": current.getValue('user_name'),
        "first_name": current.getValue('first_name'),
        "last_name": current.getValue('last_name'),
        "Sys ID": current.setNewGuidValue('259980f7936012102508fe818bba1005')   //test input as hardcoded value of sysid
    };
 
 try {
        var r = new sn_ws.RESTMessageV2('Test user sync', 'test Post');
        r.setRequestBody(JSON.stringify(body));
        var response = r.execute();
        var responseBody = response.getBody();
        gs.info('responseBody  ' + responseBody);
        var httpStatus = response.getStatusCode();
        gs.info('httpStatus  ' + httpStatus);
    } catch (ex) {
        var message = ex.message;
    }
 
    current.update();
 
When I am trying to print body then Sys ID value is not visible there. its not working for sending parameters through request body
Also one more question if I have to make that dynamic then will need to replace "Sys ID": current.setNewGuidValue('259980f7936012102508fe818bba1005') with "Sys ID": current.setNewGuidValue(current.getValue('sys_id')) right?
 
Could you please let me know if its the correct way to pass this value.

@Tejal Patil1 current.setNewGuidValue('259980f7936012102508fe818bba1005') needs to be used in onBefore Transform script on your target instance. 

Thanks for the response.

 

I used setNewGuidValue() in onBefore transform script and it is working correctly for sysid related issue but using transform map will again require some manual work like load data in lower instances and client doesn't want that. We want to completely automate this process.

 

I am currently going through ServiceNow Remote instance spoke to see if it will work for our requirement. Could you please let me know if its possible using Remote instance spoke.
FYI: We are syncing User/Group/Role/Group Members/Group Role/User Role tables

Nishant8
Giga Sage

Hello @Tejal Patil1 , Did you try to initialize the glide record first and then set the sys ID? If not, can you please try the following:

var rec = new GlideRecord('sys_user');
rec.initialize();
rec.setValue('short_description', 'Testing');
rec.setNewGuidValue('<your sys ID>');
rec.insert();

Tried this way but still not working