How to parse JSON object values in Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2022 04:11 AM
Hi,
I am having following response which I need to parse and get the text in the 'value' key shown below . Please suggest .
I have tried parse2.field47191.value but it is not working . Getting error as 'com.glide.script.RhinoEcmaError: Cannot read property "value" from undefined'
I have tried this.
var parse2 = JSON.parse(responseBody);
var wvalue = parse2.field12332.value
{
"field12332":
{
"profile":"xyzrt",
"id":6,
"value":"NY-tester-704-HXQ-NY211"
},
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2022 10:11 AM
Hi , I have tried but it was not working .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2022 10:20 AM
Hi
Did you get any errors?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2022 10:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2022 03:14 AM
Hi Mrman,
The code provided by others and the code is the original question would work. So the problem is with something else.
var responseBody = '{"firstname":"Max","phones":[{"phonetype":{"id":"D83004","formattedvalue":"Home","value":"Home"},"entry":118,"phonenumber":"+1 720 435-0088","primary":true}],"links":[{"rel":"self","title":"The current profile being viewed.","url":"https://api.test.com"}],"field12332":{"profile":"xyzrt","id":6,"value":"NY-tester-704-HXQ-NY211"},"startdate":"2022-05-25","email":"testcand0881@tester.com","lastname":"Testmax"}';
var parse2 = JSON.parse(responseBody);
var wvalue = parse2.field12332.value
Execution result:
*** Script: NY-tester-704-HXQ-NY211
The problem may be the following line in the original question.
I have tried parse2.field47191.value but it is not working .
The above sentence is using "field47191" instead of "field12332". Re-check the response body to find the actual name.