How to convert Email body to JSON in serviceNow. I need this for event creation from Email?

Rajat15
Tera Contributor

How to convert Email body to JSON in ServiceNow. I need this for event creation from Email?

4 REPLIES 4

Allen Andreas
Tera Patron

Hi,

You don't necessarily "need" to convert the email body to JSON to send it as a parm in an event. The event just needs string in the parm. It won't pass along a parsed JSON anyway...

So you can use:

var string = email.body_text;
gs.eventQueue('event_name', current, string, '');

https://docs.servicenow.com/bundle/rome-platform-administration/page/administer/platform-events/task...

Please mark reply as Helpful/Correct, if applicable. Thanks!

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Can you explain more about it. We are using flow designer to get the inbound email and then converting it to event through create record ACTION.

Now in the filters we are mapping the value of Description to body_text.

For Event Rules, when we are trying to map the values to other fields from description it is not working. 

This script which you have provided where can I utilize it in my scenario?

 

Hi,

You never said flow designer in your original post, so my reply was geared towards traditional inbound actions. With that said, please always try and give as much information as you can in your original post so people don't waste their time and reply with confusing things that aren't relevant to you.

You also didn't share that you've already pushed the body_text to another record's description field already. So several things you did not share.

You can share an example of what you have for the description field so I can see...otherwise, you'd need to parse the description field to JSON so you can use it as obj.property:

JSON.parse(record.field_name);

 

Please mark reply as Helpful/Correct, if applicable. Thanks!

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

i want to use the email body keywords as identifier, so how to get it in from email body?