Developer Resources
Create Quote & Create Order Gl...
Creating Orders (Create Order Global Method)
18 min
the https //docs nue io/create quotes and orders method ( ruby globalorderserviceapi createorder https //docs nue io/apex global methods and services ) mirrors the create quote method but creates order + orderitem records instead of quote + quotelineitem method signature ruby globalapitypes createorderresponse response = ruby globalorderserviceapi createorder(request); class ruby globalorderserviceapi method global static ruby globalapitypes createorderresponse createorder(ruby globalapitypes createorderrequest req) key differences from create quote true 220,220,222 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type request type createorderrequest ruby globalapitypes createorderrequest request = new ruby globalapitypes createorderrequest(); true 165,165,165,167 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type order header fields true 132,132,132,132,134 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type use cases 1\ basic order creation (preview) create an order with a single product in preview mode ruby globalapitypes createorderrequest request = new ruby globalapitypes createorderrequest(); order ord = new order( accountid = accountid, ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month', status = 'draft', effectivedate = date today() addmonths(12) ); request order = ord; ruby globalapitypes productinput product = new ruby globalapitypes productinput(); product productsku = 'nue platform'; product uom = 'user/month'; product quantity = 10; request products = new list\<ruby globalapitypes productinput>{ product }; request iscommit = false; ruby globalapitypes createorderresponse response = ruby globalorderserviceapi createorder(request); system assertequals('succeed', response status); system assertequals(null, response data order id, 'order should not have an id in preview mode'); system assertequals(1, response data lineitems size()); // access pricing on the line item ruby globalapitypes orderitemdto linedto = response data lineitems\[0]; orderitem oi = linedto orderitem; system debug('sku ' + oi product2 stockkeepingunit); system debug('list price ' + oi ruby listprice c); system debug('total price ' + oi ruby totalprice c); 2\ order with bundles https //docs nue io/product bundle products use the same productinput structure as quotes, including the addons list for optional add on products ruby globalapitypes createorderrequest request = new ruby globalapitypes createorderrequest(); order ord = new order( accountid = accountid, ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month', status = 'draft', effectivedate = date today() addmonths(12) ); request order = ord; ruby globalapitypes productinput bundle = new ruby globalapitypes productinput(); bundle productsku = 'nue gem edition'; bundle uom = 'user/month'; bundle quantity = 5; ruby globalapitypes productinput addon = new ruby globalapitypes productinput(); addon productsku = 'usb security key'; bundle addons = new list\<ruby globalapitypes productinput>{ addon }; request products = new list\<ruby globalapitypes productinput>{ bundle }; request iscommit = false; ruby globalapitypes createorderresponse response = ruby globalorderserviceapi createorder(request); system assertequals('succeed', response status); // response includes parent bundle + bundled items + add ons 3\ order with discounts both header level and product level discounts work identically to quotes order ord = new order( accountid = accountid, ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month', status = 'draft', effectivedate = date today() addmonths(12), ruby discount c = 10 0 // 10% header discount ); request order = ord; ruby globalapitypes productinput product = new ruby globalapitypes productinput(); product productsku = 'nue platform'; product uom = 'user/month'; product quantity = 10; product discount = 25 0; // product level discount overrides header request products = new list\<ruby globalapitypes productinput>{ product }; 4\ order with price tags https //docs nue io/price and discount tags use the same pricetaginput structure ruby globalapitypes pricetaginput tag = new ruby globalapitypes pricetaginput(); tag code = 'volume discount 10'; ruby globalapitypes productinput product = new ruby globalapitypes productinput(); product productsku = 'nue platform'; product uom = 'user/month'; product quantity = 100; product pricetags = new list\<ruby globalapitypes pricetaginput>{ tag }; request products = new list\<ruby globalapitypes productinput>{ product }; 5\ committed order set iscommit = true to persist the order and orderitems to the database request iscommit = true; ruby globalapitypes createorderresponse response = ruby globalorderserviceapi createorder(request); system assertequals('succeed', response status); system assertnotequals(null, response data order id, 'order should have a salesforce id'); // re query to confirm persistence order savedorder = \[select id, status, ruby totalprice c from order where id = \ response data order id]; system debug('order ' + savedorder id + ' | status ' + savedorder status + ' | total ' + savedorder ruby totalprice c); feature parity with create quote all features available in ruby globalquoteserviceapi createquote() are also available in ruby globalorderserviceapi createorder() true 331,331 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type the only differences are the entry point class, request/response types, and the header sobject ( order vs quote ) when to use create order vs create quote true 331,331 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type after order creation once an order is created, it can be activated to generate subscriptions, entitlements, and assets via the standard nue activation flow related services for managing orders after creation true 220,220,222 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type error handling error handling works identically to the create quote api the response includes the same status , errors , and warnings structure ruby globalapitypes createorderresponse response = ruby globalorderserviceapi createorder(request); if (response status == 'failure') { for (ruby globalapitypes message err response errors) { system debug('error \[' + err errortype + '] ' + err message); } } if (response warnings != null) { for (ruby globalapitypes message w response warnings) { system debug('warning \[' + w\ errortype + '] ' + w\ message); } } all error codes and warning codes documented in apply to the create order api as well, with the exception of quote specific codes (e g , quote opportunityid required ) the order specific validation requires accountid instead of opportunityid
Have a question?
Get answers fast with Nue’s intelligent AI, expert support team, and a growing community of users - all here to help you succeed.
To ask a question or participate in discussions, you'll need to authenticate first.