<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question CartJS - Order 2 Items via Inbound Action in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349716#M6642</link>
    <description>&lt;P&gt;We have an Onboarding catalog item that is filled in via an inbound action. I was requested to make a sperate item for facilities as they want to put an SLA at the RITM Level for IT and facilities like to leave the tasks open. So I created a separate item for facilities which basically has the same variable. Now I'm trying to order these at the same time so they are part of the same request. I'm having trouble trying to figure out how to do this with &lt;A href="https://docs.servicenow.com/bundle/paris-application-development/page/app-store/dev_portal/API_reference/CartJSScoped/concept/c_CartJSScoped.html" target="_blank" rel="noopener noreferrer"&gt;CartJS&lt;/A&gt;. I have made several attempts but it always just add the first item to the cart but never submit it. Here is the code from the last attempt. Any idea on how to get this to work?&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;values.toString().split(',');
var cart = new sn_sc.CartJS();
var item = {
    'sysparm_id': '5b776f111b04d010294520622a4bcbbe',
    'sysparm_quantity': '1',
    'variables': {
        'first_name': values[0],
        'middle_name': values[1],
        'last_name': values[2],
        'employee_id': values[3],
        'employee_type': values[4],
        'employee_manager': values[5],
        'employee_manager_email': values[6],
        'department': values[7],
        'start_date': values[8],
        'end_date': values[9],
        'managment_level': values[10],
        'work_location': values[11],
        'work_hours': values[12],
        'Manager Sup Org': values[13],
        'Employee Sup Org': values[14]
    }
};


var item2 = {
    'sysparm_id': '2247874cdbea4950750993a6f49619a4',
    'sysparm_quantity': '1',
    'variables': {
        'first_name': values[0],
        'middle_name': values[1],
        'last_name': values[2],
        'employee_id': values[3],
        'employee_type': values[4],
        'employee_manager': values[5],
        'employee_manager_email': values[6],
        'department': values[7],
        'start_date': values[8],
        'end_date': values[9],
        'managment_level': values[10],
        'work_location': values[11],
        'work_hours': values[12],
        'Manager Sup Org': values[13],
        'Employee Sup Org': values[14]
    }
};
var cartDetails = cart.addToCart(item);
cartDetails = cart.addToCart(item2);
var checkoutInfo = cart.checkoutCart();&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Mar 2022 15:48:28 GMT</pubDate>
    <dc:creator>brianlan25</dc:creator>
    <dc:date>2022-03-28T15:48:28Z</dc:date>
    <item>
      <title>CartJS - Order 2 Items via Inbound Action</title>
      <link>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349716#M6642</link>
      <description>&lt;P&gt;We have an Onboarding catalog item that is filled in via an inbound action. I was requested to make a sperate item for facilities as they want to put an SLA at the RITM Level for IT and facilities like to leave the tasks open. So I created a separate item for facilities which basically has the same variable. Now I'm trying to order these at the same time so they are part of the same request. I'm having trouble trying to figure out how to do this with &lt;A href="https://docs.servicenow.com/bundle/paris-application-development/page/app-store/dev_portal/API_reference/CartJSScoped/concept/c_CartJSScoped.html" target="_blank" rel="noopener noreferrer"&gt;CartJS&lt;/A&gt;. I have made several attempts but it always just add the first item to the cart but never submit it. Here is the code from the last attempt. Any idea on how to get this to work?&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;values.toString().split(',');
var cart = new sn_sc.CartJS();
var item = {
    'sysparm_id': '5b776f111b04d010294520622a4bcbbe',
    'sysparm_quantity': '1',
    'variables': {
        'first_name': values[0],
        'middle_name': values[1],
        'last_name': values[2],
        'employee_id': values[3],
        'employee_type': values[4],
        'employee_manager': values[5],
        'employee_manager_email': values[6],
        'department': values[7],
        'start_date': values[8],
        'end_date': values[9],
        'managment_level': values[10],
        'work_location': values[11],
        'work_hours': values[12],
        'Manager Sup Org': values[13],
        'Employee Sup Org': values[14]
    }
};


var item2 = {
    'sysparm_id': '2247874cdbea4950750993a6f49619a4',
    'sysparm_quantity': '1',
    'variables': {
        'first_name': values[0],
        'middle_name': values[1],
        'last_name': values[2],
        'employee_id': values[3],
        'employee_type': values[4],
        'employee_manager': values[5],
        'employee_manager_email': values[6],
        'department': values[7],
        'start_date': values[8],
        'end_date': values[9],
        'managment_level': values[10],
        'work_location': values[11],
        'work_hours': values[12],
        'Manager Sup Org': values[13],
        'Employee Sup Org': values[14]
    }
};
var cartDetails = cart.addToCart(item);
cartDetails = cart.addToCart(item2);
var checkoutInfo = cart.checkoutCart();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Mar 2022 15:48:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349716#M6642</guid>
      <dc:creator>brianlan25</dc:creator>
      <dc:date>2022-03-28T15:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: CartJS - Order 2 Items via Inbound Action</title>
      <link>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349717#M6643</link>
      <description>&lt;P&gt;Did you try ordering these catalog items via Service catalog REST API?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/145960i3CF78D969AB4D93F/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sachin&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 15:56:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349717#M6643</guid>
      <dc:creator>sachin_namjoshi</dc:creator>
      <dc:date>2022-03-28T15:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: CartJS - Order 2 Items via Inbound Action</title>
      <link>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349718#M6644</link>
      <description>&lt;P&gt;&lt;SN-MENTION class="sn-mention" table="live_profile" sysid="ed0252e1dbd81fc09c9ffb651f9619d1"&gt;@Brian Lancaster&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried something similar to your scenario which added me two different catalogs into cart and one request&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;for (i = 0; i &amp;lt; 2; i++) { 
var cart = new sn_sc.CartJS();
if(i==0)
{
var item =
{
'sysparm_id': 'd66518691ba10910558d639bbc4bcbc0',
'sysparm_quantity': '1',
'variables':{
'	details1': 'at_and_t_mobility', 
}};
}
else
{
var item =
{
'sysparm_id': 'a9b30d601b7a3410558d639bbc4bcb3f',
'sysparm_quantity': '1',
'variables':{
'testing': 'at_a', 
}};
}
var cartDetails = cart.addToCart(item);
gs.info(JSON.stringify(cartDetails));
}
var cartDetails = cart.orderNow(item);
gs.info(cartDetails);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cart screenshot:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/145968iB256B69A205CC46B/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Request Screenshot:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/145952iFCF1AA88556D5B9A/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Murthy&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:06:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349718#M6644</guid>
      <dc:creator>Murthy Ch</dc:creator>
      <dc:date>2022-03-28T16:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: CartJS - Order 2 Items via Inbound Action</title>
      <link>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349719#M6645</link>
      <description>&lt;P&gt;Thanks this worked preictally with one minor tweak. I had to use&amp;nbsp;cart.submitOrder(item). I'm guessing it has something to do with having two step checkout turned on.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:32:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/1349719#M6645</guid>
      <dc:creator>brianlan25</dc:creator>
      <dc:date>2022-03-28T16:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: CartJS - Order 2 Items via Inbound Action</title>
      <link>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/2505235#M976462</link>
      <description>&lt;P&gt;Hi guys!&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Thank you so much &lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/425508"&gt;@Murthy Ch&lt;/a&gt;&amp;nbsp; I got the solution because of you! I was also having problems using CartJS, my solution was like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var id_rp = gs.getProperty('prop.id_rercod_producer');
for (var i = 0; i &amp;lt; requests.length; i++) {
    var catalog_item = new sn_sc.CatItem(id_rp);
    var values = {
        'number_request': requests[id],   
        'variables': {
            'number_request': requests[i],
            'review_req': true,
            'json_req_fields': json
        }
    };
    var targetRecordDetails = catalogItem.submitProducer(values);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 19:50:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/cartjs-order-2-items-via-inbound-action/m-p/2505235#M976462</guid>
      <dc:creator>eduardo gushike</dc:creator>
      <dc:date>2023-05-05T19:50:23Z</dc:date>
    </item>
  </channel>
</rss>

