Sending JSON object via outbound REST message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 11:58 PM
I have to send incident details in the below JSON format to third party tool . I have written the REST message and business rule on incident table to invoke the REST message. Could anyone please help me with the business rule script to send below JSON object
TroubleTicketStatusChangeEvent {
id
href
eventId
eventTime
eventType
correlationId
domain
title
description
priority
timeOcurred
event {
id
href
creationDate
description
expectedResolutionDate
externalId
lastUpdate
name
priority
requestedResolutionDate
resolutionDate
severity
statusChangeDate
statusChangeReason
ticketType
attachment
channel {
id
href
name
@baseType
@schemaLocation
@type
@referredType
}
note
relatedEntity
relatedParty
status TroubleTicketStatusType
statusChange
troubleTicketRelationship
@baseType
@schemaLocation
@type
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 12:23 AM
Hello @Mahesh111 ,
you need to pass the JSON column name as string and then define the value like below sample script.
Sample example:
var r = new sn_ws.RESTMessageV2('test', 'Create Record');
var body =
'{ "fields":{ "customfield_14798":{ "value":"'+current.buService+'" }, "description":"'+current.desc+'", "customfield_14797":"'+current.clean_text+'", "customfield_15073":"'+current.number+'", "issuetype":{ "name":"'+current.temp+'" }, "duedate":"'+current.dd+'", "summary":"'+current.title+'", "reporter":{ "name":"'+current.value+'" }, "project":{ "key":"RM" } }}';
r.setRequestBody(body);
Adding links for referrence:
https://www.servicenow.com/community/developer-forum/how-to-easily-build-json-body-to-be-pass-as-a-p...
https://www.servicenow.com/community/developer-forum/rest-api-post-using-json/m-p/2153790
https://john-james-andersen.com/blog/service-now/easy-base64-encoding-in-servicenow.html
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 06:27 AM
This works from script but how to do it like passing variables to REST outbound Message?