Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Inbound Email Action Spacing Issues

RSalihar
Kilo Explorer

Hi all,

 

I have an inbound email action to automatically created incident tickets. In this inbound action I have the body of the email being copied into the description field using this line:

        current.description = email.body_text;

 

When Service Now is processing the email, it is adding an extra line return after each line.
For example, if an email has a list the looks like this:

 

Item 1

Item 2

Item 3

 

Service Now processes it as

 

Item 1

 

Item 2

 

Item 3

 

This makes my description field look extremely long. Is there any way to setup how this is brought in by the instance?

6 REPLIES 6

eican
Kilo Guru

The only way i could think of addressing this is to deplaciert all Double line breaks with a single one:



Something like:


var text = email.body_text.toString();
current.description = text.replace('\n\n', '\n');


eican's solution probably needs the global attribute:


text.replace(/\n\n/g,'\n');


Another way would be to perform a split on line breaks, and then delete any array element containing the empty string.


That would definitely work but it probably wouldn't be as efficient



Though I find this a little strange since I work with inbound actions all the time and I never get issues with extra line feeds coming through.


I have seen it a couple of times in the activity field, but only for emails sent from an Outlook client