
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 12:39 PM
Have an external system that wants to update some service-now change records with powershell. Since they only have the change number instead of the sys_id, they want to pass change number and state.
To accomplish this, I created an import set table under Web services inbound. the import set table contains u_number (String 40), u_state (String 40).
The transform map target table is change_request with u_number mapped to number (Coalesce True Choice Action Ignore) and u_state mapped to state (Coalesce Flase Choice Action Ignore). I also created a field on the import set table called CHG Updated and mapped to Due Date on the transform map so I could always have a value that changes so the update occurs (for testing).
To test, using the API explorer, copied the powershell from the parameters entered:
# Eg. User name="admin", Password="admin" for this code sample.
$user = "admin"
$pass = "bogus"
# Build auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))
# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo))
$headers.Add('Accept','application/json')
$headers.Add('Content-Type','application/json')
# Specify endpoint uri
$uri = "https://xxx.service-now.com/api/now/import/u_xxx_chg_update"
# Specify HTTP method
$method = "post"
# Specify request body
{request.body ? "$body = \"" :""}}{\"u_number\":\"CHG12345\",\"u_state\":\"1\",\"u_chg_updated\":\"2018-10-04 15:12:59\"}"}
# Send HTTP request
$response = Invoke-WebRequest -Headers $headers -Method $method -Uri $uri -Body $body
# Print response
$response.RawContent
I get an HTTP 201 Created, and the values of the import set staging table with request ignored and status_message"No field values changed"
What am i missing here?
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 09:35 AM
After rebuilding this as a new web service, kept getting error 800 on transform (800 - Unable to resolve target record, coalesce values not present: u_number) and it was not passing values, so looked at powershell script $body statement and changed format to the following:
$body=@{u_number="CHG12345";u_state="1"} | ConvertTo-Json and was able to successfully update state between closed and open.
Got to this from the article below.
https://community.servicenow.com/community?id=community_question&sys_id=74d40fe9dbd8dbc01dcaf3231f9619fb

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 01:26 AM
Hi,
purely from the message, the system does not find the sent record updated. It is the same as exists in ServiceNow already.
So it looks like everything is working fine: the system receives the record and checks for changes.
All good.
You should maybe create some modified dummy data in the call above. That way you can simulate the update if it is not possible to do this from the source system.
Let me know if that helped.
Seb

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 05:29 AM
Thanks for the reply. I have tried changing the state between open and closed and running the script. Even added the change of Due date to force a record update and get the same message. So I agree in that the request hits the import set table, since it coalesces on number it finds a match in the import set table. by changing the chg updated date with each run, that should trigger an update. I will try to add another field like short description and see if I can trigger. Can I clear the update set after transform, that way it sees the new request as a new import set table entry and updates the record with what ever changes get passed?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 09:35 AM
After rebuilding this as a new web service, kept getting error 800 on transform (800 - Unable to resolve target record, coalesce values not present: u_number) and it was not passing values, so looked at powershell script $body statement and changed format to the following:
$body=@{u_number="CHG12345";u_state="1"} | ConvertTo-Json and was able to successfully update state between closed and open.
Got to this from the article below.
https://community.servicenow.com/community?id=community_question&sys_id=74d40fe9dbd8dbc01dcaf3231f9619fb