- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2022 04:56 PM
Hi team, i am trying JSON.stringify() and JSON.parse() through email script and business rule, it is not working as expected please suggest
Business Rule:
var obj = {"preName":previous.it_application_owner.name, "curName":current.it_application_owner.name, "updatedOn":current.sys_updated_on};
var str = JSON.stringify(obj);
gs.eventQueue("sn_apm.ApplicationOwnerChanges",current,"test",str);
gs.info("@@@ business rule "+str);
Email Script:
var result = JSON.parse(event.str);
gs.info("@@@ email script " + result.preName + " was " + result.curName + " " + result.updatedOn);
template.print("\n" + "Application Owner: " + event.parm1 + " was " + event.parm2);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2022 05:01 PM
Hi @Deepthi13,
Can you tell me whether your business rule runs before or after? Can you try the below code also.
var obj = {"preName":previous.it_application_owner.name+"", "curName":current.it_application_owner.name+"", "updatedOn":current.sys_updated_on+""};
var str = JSON.stringify(obj);
gs.eventQueue("sn_apm.ApplicationOwnerChanges",current,"test",str);
gs.info("@@@ business rule "+str);
Please mark as Correct / Helpful if this solves your issue.
Regards,
Jeff

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2022 05:02 PM
So looks like you are passing the str value as event parameter 2
gs.eventQueue("sn_apm.ApplicationOwnerChanges",current,"test",str);
So you should use parm2 in the email script
var result = JSON.parse(event.parm2);
gs.info("@@@ email script " + result.preName + " was " + result.curName + " " + result.updatedOn);
template.print("\n" + "Application Owner: " + event.parm1 + " was " + event.parm2);
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2022 05:01 PM
Hi @Deepthi13,
Can you tell me whether your business rule runs before or after? Can you try the below code also.
var obj = {"preName":previous.it_application_owner.name+"", "curName":current.it_application_owner.name+"", "updatedOn":current.sys_updated_on+""};
var str = JSON.stringify(obj);
gs.eventQueue("sn_apm.ApplicationOwnerChanges",current,"test",str);
gs.info("@@@ business rule "+str);
Please mark as Correct / Helpful if this solves your issue.
Regards,
Jeff

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2022 05:02 PM
So looks like you are passing the str value as event parameter 2
gs.eventQueue("sn_apm.ApplicationOwnerChanges",current,"test",str);
So you should use parm2 in the email script
var result = JSON.parse(event.parm2);
gs.info("@@@ email script " + result.preName + " was " + result.curName + " " + result.updatedOn);
template.print("\n" + "Application Owner: " + event.parm1 + " was " + event.parm2);
Please mark this response as correct or helpful if it assisted you with your question.