- 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 02:55 AM
I don't see formatting working in infoMessage, the script that I suggest do works in scripting but for infoMessage when it changesa to HTML somehow it is not able to process. If you see below script same code is able to butify in description field but not in info message :
var x = {
"abc": "sdfa",
"test": "sadfafasf"
};
var z = JSON.stringify(x, null, 1);
gs.addInfoMessage(z);
current.description = z;
Thanks,
Kamlesh
- 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 02:45 AM
Just forgot to mention, however you can do one thing to beautify it. You can use parameters of stringify(), as shown below
var x = {"abc":"sdfa", "test":"sadfafasf"}
var z = JSON.stringify(x,null,1); // This bustifies the JSON in string format with extra space
But above butifies when you set this value in any field. Infomessage I doubt will be able to butify using parameter also.
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:50 AM
Hi ,
You are already getting the information in the JSON Format as per the screenshot shared. Please elaborate.
I tried to create in my PD. I guess this has already been achieved.
//
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.addInfoMessage('enter BS');
var payload = {
"result": {
"short_description": current.getValue('short_description'),
"active": current.getValue('active')
}
};
//var json = JSON.stringify(payload);
var json = JSON.stingify(payload);
gs.addInfoMessage(json);
})(current, previous);
I have created on Before Insert and Update and when the state is WIP. Please find the screenshot.