System fields are not populating from transform maps import.

Shruti Bhosale
Tera Contributor

I am creating case records from record producer.

I am calling cart api to place order from record producer. but it is populating only variables under variable editor but it is not setting assignment group or assigned ,comments to fields.

 

please suggest.

 

12 REPLIES 12

Shruti Bhosale
Tera Contributor

we are loading case data records which should call record producer for variables and import case records.

Shruti Bhosale
Tera Contributor
(function runTransformScript(source, map, log, target /* GlideRecord */ ) {
    var item = gs.getProperty('sn_customerservice.record producer');
    var sub = source.u_subject.getDisplayValue();
    var des = source.u_description.getDisplayValue();
    var num = source.u_number.getDisplayValue();
 
    var x;
    var acc;
    var ref = new GlideRecord("sys_user"); //Replace sys_user with any reference table
    ref.addQuery("email", source.u_contact); //Replace email with any unique field
    ref.query();
    if (ref.next()) {
        x = ref.getValue('sys_id');
        acc = ref.getValue('company');
     
        var cart = new sn_sc.CartJS();

 

        var item = {
            'sysparm_id'item,
            'sysparm_quantity''1',
            'variables': {

 

                'short_description': sub,
                'description': des,
                'number': num,
                'contact': x,
                'request_type': source.u_request_type.getDisplayValue(),
                'u_bma_updated': source.u_bma_updated.getDisplayValue(),
               
               
             {"cause":"Test"

                }




            }

 

        };
        var cartVals = cart.addToCart(item); /
        var checkoutVals = cart.checkoutCart();
        ignore = true;
 



    }
})(source, map, log, target);

Shruti Bhosale
Tera Contributor

tried this 

 {"cause":"Test"

                }

 

 

no luck

Ankur Bawiskar
Tera Patron
Tera Patron

@Shruti Bhosale 

cart API cannot set assignment group, assigned to etc

you need to explicitly update those


(function runTransformScript(source, map, log, target /* GlideRecord */ ) {
var item = gs.getProperty('sn_customerservice.record producer');
var sub = source.u_subject.getDisplayValue();
var des = source.u_description.getDisplayValue();
var num = source.u_number.getDisplayValue();

var x;
var acc;
var ref = new GlideRecord("sys_user"); //Replace sys_user with any reference table
ref.addQuery("email", source.u_contact); //Replace email with any unique field
ref.query();
if (ref.next()) {
x = ref.getValue('sys_id');
acc = ref.getValue('company');
var cart = new sn_sc.CartJS();
var item = {
'sysparm_id': item,
'sysparm_quantity': '1',
'variables': {
'short_description': sub,
'description': des,
'number': num,
'contact': x,
'request_type': source.u_request_type.getDisplayValue(),
'u_bma_updated': source.u_bma_updated.getDisplayValue(),
}
};

var cartVals = cart.addToCart(item);
var checkoutVals = cart.checkoutCart();

var parsedData = JSON.parse(checkoutVals);
var caseSysId = parsedData.request_id;

var gr = new GlideRecord("case table");
gr.addQuery("sys_id", caseSysId);
gr.query();
if (gr.next()) {
gr.assignment_group = ''; // give the group sysId here
gr.assigned_to = ''; // give the group member (user) sysId here
gr.update();
}

ignore = true;

}
})(source, map, log, target);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader