Using username from inbound email action to fill in Caller field.

gnunez
Kilo Guru

I currently use an inbound email action that captures the email in a web form outside of ServiceNow, but if the email isn't in a certain format it won't recognize who the caller is and will leave as blank. To avoid this I am trying to find a way to add to the script so it can capture the information using the username field. Is there any way to do this?

Thanks again!

1 ACCEPTED SOLUTION

Caller field is captured now. Had to add value pairs and then add that to the inbound action for Create Incident.


View solution in original post

44 REPLIES 44

drjohnchun
Tera Guru

I recently helped resolve an issue with incoming email address and am curios if this is related. That post is How to Trim Parts of Varibles from Inbound Action



Going back to your question, if the above doesn't apply to you, are you obtaining username reliably and just want to convert username to the user's sys_id so you can fill in the Caller field? If so, can you try



var gr = new GlideRecord('sys_user');


gr.query('user_name', username);


if (gr.next()) {


  var caller_id = gr.sys_id.toString();


  current.caller_id = caller_id;


}



Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


Thank you John for the quick reponse. As of now the inbound script I am using is capturing the user's email and from there will populate other fields in the incident form. The problem is that if the email isn't typed correctly, then the incident will go through but with blank fields. To avoid this I want to add a line in the code where if the email isn't correct, then it can still populate the fields using the username. Below is a screenshot of the code I currently have.



Thanks again!!



find_real_file.png


If the email does not match it will impersonate the guest account and create the incident


Hi Abhinay,



Yes I did see that but I need to create the incident using the user's account because then they won't receive a confirmation message saying they have submitted the ticket. Also, need them to receive additional comment notifications and closing ticket notification.