Developer Resources
Create Quote & Create Order Gl...
Preview Mode vs Commit Mode
10 min
the ruby globalquoteserviceapi createquote() method supports two modes of operation controlled by the iscommit flag this allows you to run the full nue pricing engine as a preview — verifying structure and calculations without persisting any data — before committing the quote as an official record overview preview ( iscommit = false ) commit ( iscommit = true ) pricing calculation full pricing engine runs full pricing engine runs database writes none — zero dml quote + quotelineitems persisted response quote id null salesforce record id response line items fully calculated fully calculated use case what if scenarios, ai validation, pricing previews creating real quotes both modes execute the identical pricing pipeline — product resolution, https //docs nue io/price books matching, https //docs nue io/product bundle expansion, https //docs nue io/price and discount tags evaluation, discount propagation, and formula calculation the only difference is whether the results are saved to the database preview mode ( iscommit = false ) preview mode allows users or integrated ai systems to simulate quote creation, verifying its structure and pricing without making permanent changes this is ideal for pricing previews — show the customer a price before creating the quote ai driven validation — let ai systems verify quote structure and interpret detailed error/warning messages before committing what if scenarios — test different quantities, terms, or discount combinations integration testing — confirm your request payloads produce expected results before going live example preview a quote opportunity opp = \[select id from opportunity where accountid != null limit 1]; ruby globalapitypes createquoterequest request = new ruby globalapitypes createquoterequest(); request quote = new quote( opportunityid = opp id, name = 'pricing preview', ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(6), ruby subscriptionterm c = 6, ruby subscriptiontermdimension c = 'month' ); ruby globalapitypes productinput prod1 = new ruby globalapitypes productinput(); prod1 productsku = 'nue on salesforce'; prod1 uom = 'user/month'; prod1 quantity = 50; ruby globalapitypes productinput prod2 = new ruby globalapitypes productinput(); prod2 productsku = 'nue platform'; prod2 uom = 'user/month'; prod2 quantity = 25; request products = new list\<ruby globalapitypes productinput>{ prod1, prod2 }; request iscommit = false; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // verify pricing is calculated system assertequals('succeed', response status); system assertequals(2, response data lineitems size()); // verify nothing was persisted system assertequals(null, response data quote id, 'quote should not have an id in preview mode'); // read calculated pricing for (ruby globalapitypes quotelineitemdto li response data lineitems) { quotelineitem qli = li quotelineitem; system debug(qli product2 stockkeepingunit + ' | qty=' + qli quantity + ' | listprice=' + qli ruby listprice c + ' | totalprice=' + qli ruby totalprice c); } // example output // nue on salesforce | qty=50 | listprice=49 90 | totalprice=14970 00 // nue platform | qty=25 | listprice=9 90 | totalprice=1485 00 what preview mode returns even though nothing is persisted, the response includes the full output of the pricing engine quote header with all calculated totals ( ruby totalprice c , ruby listtotal c , ruby subtotal c , etc ) all line items with full pricing breakdown per line applied price tags on each line item ( appliedpricetags ) — showing which price/discount tags were evaluated warnings (if any) — e g , discount precedence warnings, duplicate price tag warnings, default value notifications custom fields set on the quote header (they survive the pricing engine in memory) this makes preview mode especially valuable for ai driven workflows the system can inspect warnings and errors, adjust inputs, and re preview before committing commit mode ( iscommit = true ) commit mode finalizes quote creation, making it an official record within the system after a successful commit the quote record is inserted with all calculated pricing fields all quotelineitem records are inserted the returned quote id is the new record's salesforce id the quote appears in the salesforce ui and is linked to the opportunity example create a committed quote opportunity opp = \[select id from opportunity where accountid != null limit 1]; ruby globalapitypes createquoterequest request = new ruby globalapitypes createquoterequest(); request quote = new quote( opportunityid = opp id, name = 'committed api quote', ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month' ); ruby globalapitypes productinput prod1 = new ruby globalapitypes productinput(); prod1 productsku = 'nue on salesforce'; prod1 uom = 'user/month'; prod1 quantity = 10; ruby globalapitypes productinput prod2 = new ruby globalapitypes productinput(); prod2 productsku = 'nue platform'; prod2 uom = 'user/month'; prod2 quantity = 5; request products = new list\<ruby globalapitypes productinput>{ prod1, prod2 }; request iscommit = true; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // verify success system assertequals('succeed', response status); // quote has a real salesforce id system assertnotequals(null, response data quote id, 'quote should have an id after commit'); system debug('created quote ' + response data quote id); // line items contain both products system assertequals(2, response data lineitems size()); set\<string> skus = new set\<string>(); for (ruby globalapitypes quotelineitemdto li response data lineitems) { skus add(li quotelineitem product2 stockkeepingunit); } system assert(skus contains('nue on salesforce')); system assert(skus contains('nue platform')); // re query to confirm persistence quote savedquote = \[select id, name, ruby totalprice c from quote where id = \ response data quote id]; system debug('saved quote ' + savedquote name + ' | total ' + savedquote ruby totalprice c); common pattern preview then commit a typical integration pattern — and the recommended approach for ai driven workflows — is to preview the quote first (inspecting warnings and errors), then commit with the same payload // step 1 preview — validate structure and pricing ruby globalapitypes createquoterequest request = buildquoterequest(oppid, productinputs); request iscommit = false; ruby globalapitypes createquoteresponse preview = ruby globalquoteserviceapi createquote(request); if (preview\ status != 'succeed') { // inspect structured errors — ai can self correct based on error codes for (ruby globalapitypes message err preview\ errors) { system debug('error \[' + err errortype + '] ' + err message); } return; } // inspect warnings — ai can flag or adjust before committing if (preview\ warnings != null) { for (ruby globalapitypes message w preview\ warnings) { system debug('warning \[' + w\ errortype + '] ' + w\ message); } } // display pricing for approval decimal totalprice = preview\ data quote ruby totalprice c; system debug('total price ' + totalprice); // step 2 commit — same request, just flip the flag request iscommit = true; ruby globalapitypes createquoteresponse committed = ruby globalquoteserviceapi createquote(request); system debug('quote created ' + committed data quote id); behavior comparison behavior preview commit validation errors returned yes yes warnings returned yes yes pricing fully calculated yes yes response data quote id null salesforce id response data lineitems\[] quotelineitem id null salesforce id quote visible in salesforce ui no yes opportunity product sync (opportunity line items) no yes (async) custom fields on quote header preserved yes (in response) yes (persisted) dml statements consumed 0 multiple governor limit usage lower higher
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.