- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 01:12 AM - edited 11-07-2022 01:50 AM
I want to display AddInfoMessage in JSON format is it possible?I am getting alert in string format.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 03:00 AM - edited 11-07-2022 03:02 AM
I just did a trick and it worked. As whatever you right in the addInfoMessage it changes to HTML. So I just played a trick with the parameter of stringify() and it worked. Try the below script:
var x = {
"abc": "sdfa",
"test": "sadfafasf"
};
var z = JSON.stringify(x, null, "<br/>"); // Use break line in the last parameter
gs.addInfoMessage(z);
Just make sure you don't use it for setting value of any field as it will appear as it is.
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 01:58 AM
Hi, Can you provide the sample you were using for this?
It may be clueless to guide based on the question asked.
ServiceNow Consultant
United Kingdom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 02:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 02:27 AM - edited 11-07-2022 02:28 AM
Hi @Manjunath M ,
JSON is the format to use for exchanging info and consuming it. If you are to print the data then, you are doing it right by stringifying it. JSON is an Object and Objects are not printed, it will print in the format [object object].
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 02:37 AM
Is It possible to print like this:
"short_description" : "Email Server is down 1"
"active" : "1"
(in serparate line)