Setting field values from email with special characters

Ricky S Larsson
Tera Guru

I am trying to setup an inbound email action that set field values based on the email body text according to this SN article: Setting field values from the email body

How would I be able to read body text that use special characters? One example is that a Swedish user is supposed to write in their first name in the email. First name in Swedish is Förnamn (so the email would be written like Förnamn: Richard, and so on) 

if(email.body.förnamn!=undefined) {
	current.variables.first_name=email.body.förnamn;
}

That of course, doesn't work because of the special character Ö.

Do I have to tell them to write First Name instead, or is it possible to convert the special character somehow?

 

1 ACCEPTED SOLUTION

It seems to have some additional content in the body. Can you check if you are able to access its value in here when you stringify

for (var key in email.body) {
   var key = key.toString();
   var value = email.body[key].toString();
   gs.info("Key: "+key);
   gs.info("Value: "+value);
   if(key == 'The Value logged'){

   }
}

View solution in original post

7 REPLIES 7

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

You can use RegEx expression in the inbound action script itself in order to remove unwanted text received for special character.

Have a look here as an example:

regex: i want to check for particular special characters from input using regex

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Sri Harsha3
Tera Expert

Have you tried like

if(email.body.förnamn!=undefined) { current.variables.first_name=email.body['förnamn']; }

 

Alikutty A
Tera Sage

Hello Richard,

Have your tried email.body.f_rnamn?

SN should replace all special characters with an underscore. Please try to log it

gs.info("First Name: "+email.body.f_rnamn);

Or 

You could try this as well

for (var key in email.body) {
   gs.info("Key: "+key);
}

gs.info("First Name: "+email.body.f_rnamn);

f_rnamn returns Undefined

for (var key in email.body) {
   gs.info("Key: "+key);
}

This logs Förnamn as both fornamn and MmfornamnmM (?)

I have tried both email.body.fornamn and email.body.f_rnamnemail and both returns Undefined