- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2018 10:59 PM
Hi,
can anyone please explain how to import the data from external file to service now by using REST and SOAP method briefly. it would be better if you explain clearly with step by step.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 10:01 PM
Hello sasi,
Following is a list of steps to import data from an Outbound REST call in combination with a MID Server using a Scheduled Job and hold it with in an Import Set table using Asynchronous Import Set and Transform Map. Then schedule a job to perform the transform.
- Create a table that extends Import Set Row
- Give it a name
- Create a new application menu or Place module under Existing application menu or none
- Uncheck the auto create user role if not desired
- Create necessary columns
- Create Transform Map
- Enter name of above table with .list appended in the text filter box
- <table_name>.list
- Click on Transform Maps
- Click New
- Give it a name
- Assign the target table
- Enter name of above table with .list appended in the text filter box
- Create an import set
- Enter sys_import_set.do in text filter box
- Set mode to Asynchronous
- Keep State at Loading
- Set table to import set table created in step one
- Give description if needed
- Create Outbound REST call
- When creating the call method be sure to populate the MID Server field with desired MID Server
- Create a Scheduled Job (not a Scheduled Import) to populate the import set
- Click New
- Choose to run a script
- Set the desired times when to execute script
- Grab the scripted code from the REST call by clicking the Preview Script Usage
- Create a script that will use the REST call script usage to populate the table created in step one. You can also do any manipulation in here before populating or use the script sections in the transform map.
- Example:
try {
var r = new sn_ws.RESTMessageV2('name_of_your_outbound_rest_message', 'get');
r.setStringParameter('a_parameter', 'parameter_value');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
var results = responseBody.split(','); //This depends on what's in your response
var restGR = new GlideRecord('u_table_from_step_one');//Important
restGR.initialize();
restGR.u_assigned_to = result[0]; //this would depend on your response
restGR.u_assignment_group = result[1]; //this would depend on your response
restGR.u_short_description = result[2]; //this would depend on your response
restGR.u_description = result[3]; //this would depend on your response
restGR.sys_import_set = 'sys_id of the import set created in step 3'; //Important
restGR.insert();
- Example:
- Modify the Scheduled Job named "Asynchronous Import Set Transformer" to meet your requirements to run all Asynchronous import sets or just the one specific Rest Call import set if you haven't done your specific modifications in step 5 or in the Transform Map
For more information refer the following links:
https://docs.servicenow.com/bundle/london-application-development/page/integrate/inbound-rest/concept/c_RESTAPI.html
https://docs.servicenow.com/bundle/london-platform-administration/page/integrate/concept/c_IntegrateWThirdPartyAppsDataSrces.html
I hope that is useful and what you're looking to do.
Mark it as correct/helpful if this helps you.
Thank you!
Regards,
Shubham

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2018 11:14 PM
I'd suggest editing your post by updating the title to get more people to look at it.
Make a good to-the-point title for the question or as stackoverflow says, "Write a title that summarizes the specific problem". This helps because it lets those who can help, know they can without going into the post. You might be thinking, I can't sum it up it's too complex. No problem, try to think how you'd ask a busy colleague, and put that into the subject. If you're still having trouble, write the title last after all the details are fresh.
- Good: Set Value form variable in the request form to Table field
- Good: How to disable attachment confirmations?
- Good: How can I set an override reference qualifier to a group
- Bad: NetApp
- Bad: Photo Masking
- Bad: Not Available for Module script
https://stackoverflow.com/help/how-to-ask
Beyond that, REST/SOAP it's all http, you'll essentially have to request of the endpoint (the thing with the file) the data, then handle the response.
Generally, reading files is done on a midserver as you normally are reading corporate stuff behind firewalls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 10:01 PM
Hello sasi,
Following is a list of steps to import data from an Outbound REST call in combination with a MID Server using a Scheduled Job and hold it with in an Import Set table using Asynchronous Import Set and Transform Map. Then schedule a job to perform the transform.
- Create a table that extends Import Set Row
- Give it a name
- Create a new application menu or Place module under Existing application menu or none
- Uncheck the auto create user role if not desired
- Create necessary columns
- Create Transform Map
- Enter name of above table with .list appended in the text filter box
- <table_name>.list
- Click on Transform Maps
- Click New
- Give it a name
- Assign the target table
- Enter name of above table with .list appended in the text filter box
- Create an import set
- Enter sys_import_set.do in text filter box
- Set mode to Asynchronous
- Keep State at Loading
- Set table to import set table created in step one
- Give description if needed
- Create Outbound REST call
- When creating the call method be sure to populate the MID Server field with desired MID Server
- Create a Scheduled Job (not a Scheduled Import) to populate the import set
- Click New
- Choose to run a script
- Set the desired times when to execute script
- Grab the scripted code from the REST call by clicking the Preview Script Usage
- Create a script that will use the REST call script usage to populate the table created in step one. You can also do any manipulation in here before populating or use the script sections in the transform map.
- Example:
try {
var r = new sn_ws.RESTMessageV2('name_of_your_outbound_rest_message', 'get');
r.setStringParameter('a_parameter', 'parameter_value');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
var results = responseBody.split(','); //This depends on what's in your response
var restGR = new GlideRecord('u_table_from_step_one');//Important
restGR.initialize();
restGR.u_assigned_to = result[0]; //this would depend on your response
restGR.u_assignment_group = result[1]; //this would depend on your response
restGR.u_short_description = result[2]; //this would depend on your response
restGR.u_description = result[3]; //this would depend on your response
restGR.sys_import_set = 'sys_id of the import set created in step 3'; //Important
restGR.insert();
- Example:
- Modify the Scheduled Job named "Asynchronous Import Set Transformer" to meet your requirements to run all Asynchronous import sets or just the one specific Rest Call import set if you haven't done your specific modifications in step 5 or in the Transform Map
For more information refer the following links:
https://docs.servicenow.com/bundle/london-application-development/page/integrate/inbound-rest/concept/c_RESTAPI.html
https://docs.servicenow.com/bundle/london-platform-administration/page/integrate/concept/c_IntegrateWThirdPartyAppsDataSrces.html
I hope that is useful and what you're looking to do.
Mark it as correct/helpful if this helps you.
Thank you!
Regards,
Shubham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 06:26 PM
Hello Shubham!
On the London release, when I try to execute step 3 (Create an Import Set), and I
- Enter sys_import_set.do in text filter box
I get the form with the new import set, but all the fields are read only and the field "Import set table" is invisible, so I cannot set import set table (created in Step 1) to that import set (although I am doing this as "admin"). Can you, please, tell me what am I missing?
Regards,
Zivan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 08:43 AM
I have the same problem as Zivan... :
On the London release, when I try to execute step 3 (Create an Import Set), and I
- Enter sys_import_set.do in text filter box
All fields are read only
Thanks,
hlima