How to create a sync from Dev & Test to disable internal users in both when disabled in production?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 04:46 AM
When users are removed from AD and disabled in SN Prod - We want to have Dev/Test sync up to disable their accounts as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 08:42 AM
Hi Mouktik,
You can achieve that by Instance to Instance REST integration.
Assuming that you have Integration hub and Flow designer, I'm sharing the steps to fulfill your requirement.
Step 1: Get the API
In your Production instance, use the REST API Explorer to get an API for fetching recently updated user records.
Fields to fill in REST API Explorer:
Table: User (sys_user)
sysparm_query: sys_updated_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()
The API would look like the below.
https://{instance_name}.service-now.com/api/now/table/sys_user?sysparm_query=sys_updated_onONLast%2015%20minutes%40javascript%3Ags.beginningOfLast15Minutes()%40javascript%3Ags.endOfLast15Minutes()&sysparm_limit=10
Please remove the last part "sysparm_limit=10" while using this API in future steps.
-----------------------------------------------------------------------------------------------------------------------------------------
Step 2: Create Data Source
In your DEV/TEST instance,
Please create a Data Source as below.
Below are the fields which needs to be filled while creating a Data Source.
Fields | Value | Description |
Name | Name of the Data Source. | |
Import set table name | The table will be created in further steps, but you can enter the table name which you'll create in next steps (Step 3). | |
Type | REST (integrationHub) | Will be available only if you have IntegrationHub which is necessary to implement using this method. |
Format | JSON | Format of the API created in Production instance. |
Path for each row | /result/* | The path expression used to select JSON objects, which will become rows in the import set table. The path should be // for JSON objects. |
Request action | Data source request action that will be invoked to get data. We'll create this in the next step (Step 2.1). |
For more details: https://docs.servicenow.com/bundle/tokyo-platform-administration/page/administer/import-sets/referen...
Step 2.1: Create request action
You can create a new requestion action from the previous form.
Below are the fields which needs to be filled while creating a Request action.
Resource path: /api/now/table/sys_user?sysparm_query=sys_updated_onONLast%2015%20minutes%40javascript%3Ags.beginningOfLast15Minutes()%40javascript%3Ags.endOfLast15Minutes()
Fields | Value | Description |
Connection | Define Connection inline | Define connection information within this action step. |
Credential alias | Credential of the integration user in your Production instance. Note: The user should have the "rest_service" and the role to view the table. In my case "itil". More details will be shared in the next step (Step 2.2.1). | |
Base URL | https://{instance_name}.service-now.com/ | Base URL of your Production instance. |
Build Request | Manually | Create action inputs and complete the REST step form manually. |
Resourse path | Path for the resource. (Creating in the Step 1). | |
Http Method | GET | HTTP method used to process the request. Since we are going to get the user details from Production the value is GET. |
To verify whether we are getting the data from Production instance, you can click the "Test" button displayed on the top right. you can enter any name for the attachment, the response from the API will get stored in the "sys_attachment" table.
For more details: https://docs.servicenow.com/bundle/washingtondc-build-workflows/page/administer/flow-designer/refere...
Step 2.2.1: Create credential alias
- Create a new alias by clicking the + icon. You'll be prompted to Auth types.
- Click Basic Auth or Auth type of your preference. (For demo I'm creating Basic Auth).
- Unlock the Credentials Alias -> click the loop up icon(magnifying glass) -> click new button.
- Change the type to Credentials and enter a name of your preference.
- Once the Connection alias is created, from the "Credentials" related list tab click new, select the Basic Auth Credentials and enter the username and password of the user which we created earlier in Production instance.
- Select this Credential alias for the REST Action (Step 2.1).
Step 3: Load data and Create Transform map
- System Import sets -> Load data.
- Create a table and enter the label same as step 2 and select the data source which was created in step 2.
- Create a transform map and auto map all the fields and set the coalesce field.
- Click Transform related link to import the values into Test/Dev instance.
Step 4: Create a scheduled Import of data
- Schedule imports -> select the Data Source which we created in Step 2 and choose Run - Periodically and select the repeat interval as per your requirement. In my case it is 15 minutes.
By this way, you can update the user records in Production and get it reflected in QA/DEV automatically.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.
Best regards,
Tharun Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 08:52 AM
Review Instance Data Replication (https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/administer/instance-data-re... in case if it helps.
Regards,
Sharad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 08:59 PM
hi @Mouktik_B,
did you ever tried the instance data replication?