Skip to main content

Consuming a staging table endpoint & transform map using REST

whilst below works, developer site actually recommends the format:
/api/now/import/<staging table_name>

https://developer.servicenow.com/app.do#!/rest_api_doc?v=kingston&id=c_ImportSetAPI

-------------------


web service endpoint created in a remote ServiceNow instance via system web services> create new,
where the staging table name is u_staging_table_xyz and the requests are processed to the target table via a transform map

SOAP wsdl to consume from another ServiceNow instance might be

    https://<servicenowinstance>.service-now.com/u_staging_table_xyz.do?WSDL

format for consuming this on REST would be:

    https://<servicenowinstance>.service-now.com/api/now/table/u_staging_table_xyz 



Example test harness for a POST operation

 go to REST messages and create a new REST message as a test harness, and create a new http POST method:




set up a basic authentication profile and configure the authentication profile to use as credentials (use a test user in the target instance with the REST role) below example highlights how to pull in variable substitutions into the content using "field_name": "${variable_sub}", format




[copy JSON:
{
"u_code": "${u_code}",
"u_short_description": "this is a test",
"u_vendor_reference": "${u_vendor_reference}",
"u_vendor_reference_sys_id": "c0d2d2b2db2ce7804735323239961993",
"u_short_description": "test",
"u_work_notes": "test update",
"u_state": "15",
"u_number": "${u_number}",
"u_caller_id": ""

}

note: the transform map might be configured to coalesce on the 3rd party reference number and to reject updates if the u_number element is not populated with a pre-existing number
]

Comments

Popular posts from this blog

URL link in addInfoMessage

var ga=new GlideAjax('gld_HR_ajax'); ga.addParam('sysparm_name', 'checkEmployeeNumber_hrProfile'); ga.addParam('sysparm_hrprofilenumber', g_form.getValue('number')); ga.addParam('sysparm_employeenumber', newValue); ga.getXMLAnswer(function(answer) { if (answer!='undefined' && answer!=''){ var navURL="<a style='text-decoration:underline;color:blue' href=hr_profile.do?sysparm_query=number=" + answer + ">" + answer + "</a><img width='3' src='images/s.gif'/>"; var sMsg='The employee number entered already exists on another HR Profile ' + navURL; //alert(sMsg); g_form.showErrorBox('employee_number', 'error - please check'); g_form.addInfoMessage(sMsg); } });

GlideRecord setValue

setValue(String name, Object value) Sets the specified field to the specified value. Normally a script would do a direct assignment, for example,  gr.category = value . However, if in a script the element name is a variable, then  gr.setValue(elementName, value)  can be used. When setting a value, ensure the data type of the field matches the data type of the value you enter. This method cannot be used on journal fields. If the value parameter is null, the record is not updated, and an error is not thrown https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_GlideRecord-setValue_String_Object