- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 09:19 AM
Hello Community!
I am running an inbound email action to parse out an email. I am then using the set display value method on variables on my form that it creates. Some variables are filling in and working and some are not. I am hoping you can help me figure out why. Below is a copy of my inbound email action, and some form info. One weird thing that is happening is that it will set the job title to a value like a string, but you can't see it on the form and it's not referencing that table.
INBOUND EMAIL
--------------------------------------------------------------------------------------------------------------------------
Hello IT Service Desk,
This is a request for IT to setup for the new hire.
New Hire Name: Emily M Vranes
New Hire/Rehire: Yes - New Hire
Position: Customer Support Rep Level I
Department: Client Support - UT
Location: Draper Headquarters
Needs Laptop: No
Orientation Date: 2018-08-06
Start Date: Monday, August 06, 2018
Reporting Manager: Eva Ariceaga
Manager's email: ***.****@****leasing.com
Thank you,
HR Department
--------------------------------------------------------------------------------------------------------------------------
INBOUND EMAIL ACTION
var email_string = email.body_text.toString();
var names = email.body.new_hire_name.toString().split(' ');
var username = email.body.new_hire_name;
var manager = email.body.reporting_manager;
var location = email.body.location;
var job_title = email.body.position;
var department = email.body.department;
var needs_laptop = email.body.needs_laptop;
var start_date = email.body.orientation_date;
var email_sys_id = sys_email.sys_id;
current.initialize();
current.u_new_hire_manager = manager;
if (names.length == 2)
{
current.u_first_name = names[0];
current.u_last_name = names[1];
}
if (names.length == 3)
{
current.u_first_name = names[0];
current.u_last_name = names[2];
}
current.u_username = username;
current.u_location.setDisplayValue(email.body.location);
current.u_job_title.setDisplayValue(email.body.position);
current.u_department.setDisplayValue(email.body.department);
if (needs_laptop == 'Yes')
{
current.u_needs_laptop = true;
}
if (needs_laptop == 'No')
{
current.u_needs_laptop = false;
}
current.u_start_date = start_date;
current.description = email_string;
current.state = 1;
current.assignment_group = '3adacb8813ad6e00d9ff30ded144b011';
current.short_description = 'New Hire Onboarding - ' + username;
current.reference_email = email_sys_id;
current.insert();
THE CREATED RECORD FROM THE INBOUND ACTION
I filled in Location, Start Date, Job Title, and Department. Those are the fields that are not auto filling, every other field is auto filling from my inbound action. Any tips or help or questions would be great, thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 12:24 PM
the freaking email that we were getting sent had " " spaces in front (face palm) just added .trim() to my variables that were not mapping over, and that fixed it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 10:06 AM
thanks for the reply! yeah, they all are in the table. We just cloned our production instance back to our RC instance and I was able to test an onboarding email like above in RC and everything worked fine. We just cloned back over the weekend.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 12:24 PM
the freaking email that we were getting sent had " " spaces in front (face palm) just added .trim() to my variables that were not mapping over, and that fixed it!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 10:26 AM
it seems reference fields are not populating in your target table.
Please make sure that you are inserting sys_id for reference field data in your inbound action code.
Please modify your code like below
ar email_string = email.body_text.toString();
var names = email.body.new_hire_name.toString().split(' ');
var username = email.body.new_hire_name;
var manager = email.body.reporting_manager;
var location = email.body.location;
var job_title = email.body.position;
var department = email.body.department;
var needs_laptop = email.body.needs_laptop;
var start_date = email.body.orientation_date;
var email_sys_id = sys_email.sys_id;
var loc = new GlideRecord('cmn_location');
loc.addQuery('name',location);
loc.query();
while(loc.next()){
var lc = loc.sys_id;
}
current.initialize();
current.u_new_hire_manager = manager;
if (names.length == 2)
{
current.u_first_name = names[0];
current.u_last_name = names[1];
}
if (names.length == 3)
{
current.u_first_name = names[0];
current.u_last_name = names[2];
}
current.u_username = username;
//current.u_location.setDisplayValue(email.body.location);// sys_id of location
current.u_location = lc;
current.u_job_title.setDisplayValue(email.body.position); // sys_id of job tilte
current.u_department.setDisplayValue(email.body.department); // sys_id of department
if (needs_laptop == 'Yes')
{
current.u_needs_laptop = true;
}
if (needs_laptop == 'No')
{
current.u_needs_laptop = false;
}
current.u_start_date = start_date;
current.description = email_string;
current.state = 1;
current.assignment_group = '3adacb8813ad6e00d9ff30ded144b011';
current.short_description = 'New Hire Onboarding - ' + username;
current.reference_email = email_sys_id;
current.insert();
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 12:25 PM
thanks for you help on this.
the freaking email that we were getting sent had " " spaces in front (face palm) just added .trim() to my variables that were not mapping over, and that fixed it!