Inbound Email Parsing - Name/Value pairs

Andrew Bettcher
Kilo Sage

 

Hi All,

I'm having a weird result when trying to parse an email to populate fields on a form using name/value pairs (as discussed here and elsewhere).

My inbound action code looks like this:

if (email.body.corrective_action != undefined){
	current.u_first_response_corrective_action = email.body.first_response_corrective_action;
}
if (email.body.suspected_cause != undefined){
	current.u_suspected_cause = email.body.suspected_cause;
}
if (email.body.corrective_action_follow_up != undefined){
	current.u_corrective_action_follow_up = email.body.corrective_action_follow_up;
	}

All of the fields mentioned are simple string fields.

The weird part is that the "suspected_cause" works fine but the other two don't.

This page says:

Note: Spaces are rendered as underscores when a name:value pair gets parsed into a variable/value pair. For example, if an email body contains a line with spaces like my variable:data, then the inbound email script creates the variable email.body.my_variable. The value of the variable is data.

And so I think my names are OK but the only thing I can think of is that the one that works only contains one space/underscore and the other's have multiple spaces/underscores. However, I've tried with another field that has only one and it still doesn't work.

The question is then, why does one work and not the others? (I'm hoping no one spots a missing comma or colon or something. I've checked it over and over.....)

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi

Check the field names.

In the if conditon, you have used email.body.corrective_action whereas inside if you have used email.body.first_response_corrective_action;

Also add this line to check the actual values in the 1st line of inbound action

gs.log("Values are "+email.body.corrective_action_follow_up+"---"+email.body.first_response_corrective_action);

Mark the comment as helpful/correct if this solves the problem.

View solution in original post

6 REPLIES 6

Excellent. You were right. The field name was wrong. I'd called it "u_first_respone_corrective_active"

What a fool I am. Thank you for pointing me in the right direction.

I don't use log statements enough in my coding and it's something that would help enormously. So thank you again.

Glad the issue is resolved.

Yes, the log statements helps a lot to debug the issue.