The CreatorCon Call for Content is officially open! Get started here.

Retrieve value from Response.getBody() in JSON

manish123
Giga Guru

Hi All,

In REST integration, we are getting Response.getBody() with lots of fields and values respective to it. However, i would like to get some specific value from that Response.Could anyone please let me know how to get that? I tried with decode and Parse but still in log its displaying undefined.

1 ACCEPTED SOLUTION

Result does not appear to be an array. I'm reaching this as:



gs.log('Number=' + jsonObject.result.number);


View solution in original post

42 REPLIES 42

Its After Business rule

 

Yes its a typo from my end instead of copying complete rest Response, I typed only that combo

 

I'm able to see the summary successfully in log, but not able to set in the field 😞

If it's after, there's your issue. You are trying to update a field on the current record AFTER the system does the save to the record. It's a bit like holding out your train ticket after the train has left the station. You're not getting on that ride.

Instead, change it to a BEFORE business rule so you can get the value in to the current object, then the system does the save.

Ohh WOw, that did the trick.

Now i caught right train 🙂

 

 

Thanks a lot

You are welcome. A common mistake. I'll cover it on today's community live stream.

try this:

var jsonObject = JSON.parse(responseBody);
 gs.info('Summary='+jsonObject.summary);
current.setValue('u_jira_sys_id',jsonObject.summary);