Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Create Requested Item with all variables from Inbound Action

Samiksha2
Mega Sage

Hi All,

 

I have a requirement to create Requested Item with all the variables from Inbound Action.

Catalog form name: Generic Request

Variables- Requested for -(referring to sys_user)

Email- Autopopulate based on Requested for

Account - lookup select box(refer to customer_account)

Client - lookup select box(refer to customer_account, name= Id. I have added reference qualifier. based on account Id will show)

Short description- Single text line

Description- HTML text

 

I have created Inbound action on sc_request table( I take help from this community link https://www.servicenow.com/community/developer-forum/create-requested-item-from-inbound-action-with-... )

(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

    var user = new GlideRecord('customer_contact');
    user.addQuery('email', email.from.toLowerCase());
    user.query(); //search contact table for user
    if (user.next()) {
        var requested_for = user.sys_id;
        if (user.account) { 
            var account = user.account.getDisplayValue();
            var account_id = new GlideRecord('customer_account');
            account_id.addEncodedQuery('name=' + account);
            account_id.query();
            if (account_id.next()) {
                var client = account_id.u_client.getDisplayValue();
            }
        } else {
            //do nothing
        }
    }
    var cartID = GlideGuid.generate(null);
    var cart = new Cart(cartID);
    var item = cart.addItem('562790589388b11034dbbb2c5cbu1908');
    cart.setVariable(item, 'account_hidden', account);
    cart.setVariable(item, 'client', client);
    cart.setVariable(item, 'short_description', email.subject);
    cart.setVariable(item, 'description', email.body_html);
    var rc = cart.placeOrder();

    var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('request', rc.getValue('sys_id'));
    ritm.query();
    if (ritm.next()) {
        ritm.short_description = email.subject;
        ritm.description = email.body_html;
        ritm.comments = email.body_text;
        ritm.requested_for = gs.getUserID();
        ritm.contact_type = "email";
        ritm.update();
    }
})(current, event, email, logger, classifier);

 I am only receiving the mail. Request , requested item nothing is generating. 

Please help in this.

 

Thanks,

Samiksha

10 REPLIES 10

Hi @Mohith Devatte ,

 

I have used FD to submit the request through Email and it works.

Thanks for your all help.