Catalog item submission from inbound action

LaraReddy
Tera Guru

Hi All,

We have used the below inbound action script to submit the catalog item and it's working fine BUT the variable set variables are not populating even through variable set variables are populated during the submission of catalog item.

Since we are new to these inbound actions, we are not sure how to pass the requested for user's manager name to variable set variable and call the same on below script level.

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

    var cartID = GlideGuid.generate(null);
    var cart = new Cart(cartID);
    var item = cart.addItem('c1841dde1bb63f806c47419ead4bcbc5');
    cart.setVariable(item,'oar_additional_access',email.body_text);
    var rc = cart.placeOrder();

 var ritm = new GlideRecord("sc_req_item");
 ritm.addQuery("request",rc.sys_id);
 ritm.query();
 if(ritm.next())
{
ritm.short_description = email.subject.toString();
ritm.contact_type = "email";
ritm.update();

}
})(current, event, email, logger, classifier);


Advance thanks.
6 REPLIES 6

Hi Ankur,
Many thanks for the response.
DO you want us to give the direct userSysID to populate the requester for user's manager name.

Not sure we followed you, could you please check the below script once and share your thoughts to fix the issue.


 

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

    // Implement email action here


     var sid = gs.createUser(email.from);
    // current.opened_by = sid;

    var cartID = GlideGuid.generate(null);
    var cart = new Cart(cartID);
    var item = cart.addItem('bc4ea1751bd435d04649c845604bcb7f');
    cart.setVariable(item, 'description', email.body_text);
    cart.setVariable(item, 'short_description',email.subject.toString());
    cart.setVariable(item, 'curr_date',gs.nowDateTime());
    cart.setVariable(item, 'assignment_group','b97e89b94a36231201676b73322a0311');
    cart.setVariable(item, 'assigned_to',sid);

    // get the user's manager name
    var userGr = new GlideRecord('sys_user');
if (userGr.get(current.requested_for)) {  // inbound action running on sc_request table
        var managerUser = new GlideRecord('sys_user');
        if (managerUser.get(userGr.manager.name))
{
            var managerName = managerUser.getDisplayName();
            cart.setVariable(item,'catItemDef_manager',managerName);
        }
    }

    var rc = cart.placeOrder();

    var ritm = new GlideRecord("sc_req_item");
    ritm.addQuery("request", rc.sys_id);
    ritm.query();
    if (ritm.next()) {

        ritm.short_description = email.subject.toString();
        ritm.contact_type = "email";
        ritm.update();

    }
})(current, event, email, logger, classifier);


Advance thanks.

Hi @Ankur Bawiskar and all,
Could you please help us on the issue.

Thanks.