- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 06:39 AM
I am still learning...and scripting is still not natural to me. I found this: Using username from inbound email action to fill in Caller field.
That seems close to what I want to do. Here is the situation: I am trying to retire a system and rather than re-invent everything in service now all at once (which is overwhelming) and changing behaviors all at once, I am taking an incremental approach. So, I am switching incident and requests to service-now - but I'm keeping the forms we use, which are not in service-now - some are in jot-form and some are in confluence. Confluence is internal and the sender of emails into service-now is what I want it to be - the manager making the request. But for jot-form - the sender is "noreply@jotform.com". That is NOT what I want it to be. I have a field in the jot-form for the manager, or whoever is filling out the form to enter the manager's email address. I know how to set all the cart variables in an inbound action from the email body that comes into service now. But I can't figure out how to key off of that manager's email to set the "requested_for" field.
Try not to laugh - but here is my script so far. I tried adding that little section at the beginning (text in purple) to set the requested_for...but it doesn't work... I really have no idea what I'm doing. The rest of it works...all the other variables get set.:
current.description = email.body_text;
createRequest();
function createRequest() {
var cart = new Cart();
// add in cart
var item = cart.addItem('ae8c854e0f374700522a419ce1050ee3');
// set requested for
var gr = new GlideRecord('sys_user');
gr.query('mgr_email', email);
if (gr.next()) {
var caller_id = gr.sys_id.toString();
current.requested_for = caller_id;
}
cart.setVariable(item, 'first_name', email.body.first_name);
cart.setVariable(item, 'last_name', email.body.last_name);
cart.setVariable(item, 'pref_name', email.body.pref_name);
cart.setVariable(item, 'mgr_name', email.body.mgr_name);
cart.setVariable(item, 'mgr_email', email.body.mgr_email);
cart.setVariable(item, 'notes', email.body.notes);
cart.setVariable(item, 'wir_acct_fn', email.body.wir_acct_fn);
cart.setVariable(item, 'wir_acct_ln', email.body.wir_acct_ln);
cart.setVariable(item, 'wir_acct_area_code', email.body.wir_acct_area_code);
cart.setVariable(item, 'wir_acct_num_ph_num', email.body.wir_acct_num_ph_num);
cart.setVariable(item, 'ac_pn_to_trans', email.body.ac_pn_to_trans);
cart.setVariable(item, 'pn_trans_becks', email.body.pn_trans_becks);
cart.setVariable(item, 'cur_cell_prov', email.body.cur_cell_prov);
cart.setVariable(item, 'wir_acct_num', email.body.wir_acct_num);
cart.setVariable(item, 'wir_st_ln1', email.body.wir_st_ln1);
cart.setVariable(item, 'wir_st_ln2', email.body.wir_st_ln2);
cart.setVariable(item, 'wir_city', email.body.wir_city);
cart.setVariable(item, 'wir_state', email.body.wir_state);
cart.setVariable(item, 'wir_zip', email.body.wir_zip);
cart.setVariable(item, 'wir_country', email.body.wir_country);
cart.setVariable(item, 'wir_ssn', email.body.wir_ssn);
cart.setVariable(item, 'wir_pass', email.body.wir_pass);
//cart.setVariable(item, 'request_type', 'others');
//cart.setVariable(item, "notes",email.body_text);
// set application
//cart.setVariable(item, 'application', '3243d574bd05300071578913764fb117');
// set assignment group
//cart.setVariable(item, 'requested_for', "afe777670fc88300522a419ce1050e57");
//cart.setVariable(item, 'priority', 'PR3');
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item,'comments',cartmsg);
var rc = cart.placeOrder();
Thanks in advance for your help!
Daniel
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 11:00 AM
I was able to get what I wanted by adding this:
var request = new GlideRecord('sc_request');
if (request.get(current.request)) {
request.requested_for = current.variables.mgr_email.toString();
request.update();
}
to the Workflow script. I still don't understand entirely what I'm doing. I have no idea what a gliderecord is. or what the syntax is saying exactly...but it worked! And I found the answer here:
Set 'Requested For' in Workflow Script Activity not working ONLY in Firefox?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 11:00 AM
I was able to get what I wanted by adding this:
var request = new GlideRecord('sc_request');
if (request.get(current.request)) {
request.requested_for = current.variables.mgr_email.toString();
request.update();
}
to the Workflow script. I still don't understand entirely what I'm doing. I have no idea what a gliderecord is. or what the syntax is saying exactly...but it worked! And I found the answer here:
Set 'Requested For' in Workflow Script Activity not working ONLY in Firefox?!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 11:09 AM
You are creating an object instance of sc_request table by doing GlideRecord and query the particular record you created.
You are running this business rule on RITM,because your variables such as manager is stored in RITM.
Then query request table to get the associated RITM and updating the requested for to the manager emails from the mgr_email variable in RITM and setting the requested for.
Please mark this response as correct or helpful if it assisted you with your question.