- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 09:34 AM
Hi team,
we are using BR to fetching the incident record values, but unable to create a nested JSON pattern as below
{
"requestor": "test",
"email": "abc@xyz.com",
"Details": [{
"name": "test",
"age": "New",
"place": "",
"action": "Add",
"city": ["ABC", "XYZ"]},
{"name": "yes",
"age": "New",
"place": "hello",
"action": "Add",
"city": ["ABC", "XYZ"]}
]}
Where Details will dynamically add, depends on users info and city attribute is an array and how the REST message should set to the above JSON
Any suggestions, please
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 10:45 AM
If you are working with a GlideList field, the following is an example that may help you
var obj = {
requestor: current.getDisplayValue('caller_id'),
email: current.caller_id.email.toString(),
Details: []
};
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id', 'IN', current.getValue('watch_list'));
userGR.query();
while(userGR.next()) {
obj.Details.push({
name: userGR.getValue('user_name')
});
}
Which would generate a JSON that looks like
{
"requestor": "Abel Tuter",
"email": "abel.tuter@example.com",
"Details": [
{
"name": "adela.cervantsz"
},
{
"name": "aileen.mottern"
},
{
"name": "abraham.lincoln"
}
]
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 10:31 AM
Is the information on multiple users added to a List (GlideList) element?
Maybe add a screenshot of the form you're trying to generate the data from and highlight the field(s) you are trying to get the data from.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 10:45 AM
If you are working with a GlideList field, the following is an example that may help you
var obj = {
requestor: current.getDisplayValue('caller_id'),
email: current.caller_id.email.toString(),
Details: []
};
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id', 'IN', current.getValue('watch_list'));
userGR.query();
while(userGR.next()) {
obj.Details.push({
name: userGR.getValue('user_name')
});
}
Which would generate a JSON that looks like
{
"requestor": "Abel Tuter",
"email": "abel.tuter@example.com",
"Details": [
{
"name": "adela.cervantsz"
},
{
"name": "aileen.mottern"
},
{
"name": "abraham.lincoln"
}
]
}