- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 08:01 AM
How to send data in the below format?
"name": "Invalid Test",
"created": {
"date_time": "2018-04-18T15:33:00",
"time_zone": "America/New_York"
},
I have able to send data for the name field but not able to send for created since it has some different format. In Rest Message variable substitution related list, we have one to one field mapping. like name to name, date_time to date_time, number to number but this is something different.
Anybody share some idea how to handle this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 08:06 AM
Hi Swathi,
Have those many variable substitutions in your rest message function and substitute those individually using setStringParameter()
your request body before substitution should look like
"name": "${name}",
"created": {
"date_time": "${date_time}",
"time_zone": "${time_zone}"
},
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 08:06 AM
Hi Swathi,
Have those many variable substitutions in your rest message function and substitute those individually using setStringParameter()
your request body before substitution should look like
"name": "${name}",
"created": {
"date_time": "${date_time}",
"time_zone": "${time_zone}"
},
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 08:13 AM
currently I have a business rule in which I am setting value below like this
r.setStringParameterNoEscape('name', current.short_description);
how to set for this? Can you set it and give me one example please?
"created": {
"date_time": "2018-04-18T15:33:00",
"time_zone": "America/New_York"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 08:22 AM
Hi Swathi,
Once you have defined the variable substitution for the other 2 variables also have this in your business rule
r.setStringParameterNoEscape('date_time', current.<dateTimeField>);
r.setStringParameterNoEscape('time_zone', timeZone);
For timezone if you want to set system time zone then use gs.getProperty("glide.sys.default.tz")
if you want the user's timezone in whose session this BR triggers then use this gs.getUser().getTZ()
var timeZone = use either of above 2 lines of code as per timezone required.
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 08:30 AM
Got it, in the content field itself I modified as you said and it worked.
"created": {
"date_time": "${date_time}",
"time_zone": "${time_zone}"
}