
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2020 01:50 AM
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.....)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2020 02:25 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2020 02:06 AM
Try this:
if (email.body.first_response_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;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2020 02:25 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2020 04:07 AM
Hi,
I spotted that mismatch after I'd posted the question. That an attempt to make the field have only one underscore to test my theory. I discounted this as being part of the issue.
I added that line and sent my test email. I looked at the log and I couldn't see the expected error line but I did see this:
Values are undefined--- followed by the text that I expected to be added to the "u_first_response_corrective_action" field. That's handy,
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2020 04:15 AM
Hi - Sorry. I found the log entry and it says what I typed as the value in the email I sent.