Developer Resources
Create Quote & Create Order Gl...
Custom Fields on Quotes
9 min
the ruby globalquoteserviceapi createquote() https //docs nue io/apex global methods and services method supports passing https //docs nue io/manage custom attributes in price book entries on the quote header custom fields are set via the standard salesforce sobject put() method on the quote before passing it in the request setting custom fields on the quote header because custom fields are not known at compile time, you cannot pass them as constructor arguments on the quote sobject instead, use the put() method to set field values dynamically quote q = new quote( opportunityid = oppid, name = 'custom fields test', ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month' ); // set custom fields via put() q put('customtext c', 'hello from api'); q put('customnumber c', 42 50); q put('customdate c', date newinstance(2026, 6, 15)); this works for any field type supported by salesforce text, number, date, datetime, checkbox, picklist, currency, etc use cases 1\ custom fields on header (committed) set custom text, number, and date fields on the quote header and commit the quote to persist them in the database ruby globalapitypes createquoterequest request = new ruby globalapitypes createquoterequest(); quote q = new quote( opportunityid = oppid, name = 'custom fields committed', ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month' ); q put('customtext c', 'hello from api'); q put('customnumber c', 42 50); q put('customdate c', date newinstance(2026, 6, 15)); request quote = q; 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 = true; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // after commit re query to verify fields persisted quote savedquote = \[ select id, customtext c, customnumber c, customdate c from quote where id = \ response data quote id ]; system assertequals('hello from api', savedquote get('customtext c')); system assertequals(42 50, savedquote get('customnumber c')); system assertequals(date newinstance(2026, 6, 15), savedquote get('customdate c')); 2\ custom fields on header (preview) the same custom fields are returned in the response even in preview mode ( iscommit = false ), although they are not persisted to the database ruby globalapitypes createquoterequest request = new ruby globalapitypes createquoterequest(); quote q = new quote( opportunityid = oppid, name = 'custom fields preview', ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month' ); q put('customtext c', 'hello from api'); q put('customnumber c', 42 50); q put('customdate c', date newinstance(2026, 6, 15)); request quote = q; 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 createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // custom fields are available in the response even without committing object textval = response data quote get('customtext c'); system assertequals('hello from api', textval); object numval = response data quote get('customnumber c'); system assertequals(42 50, numval); 3\ custom fields survive bundle pricing custom fields set on the quote header are preserved even when the pricing engine processes https //docs nue io/product bundle products with add ons the bundle expansion and pricing pipeline does not strip or overwrite custom fields quote q = new quote( opportunityid = oppid, name = 'bundle with custom fields', ruby subscriptionstartdate c = date today(), ruby subscriptionenddate c = date today() addmonths(12), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month' ); q put('customtext c', 'survives bundle pricing'); request quote = q; // add a bundle product with an add on 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 = true; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // custom field is still present after bundle processing object textval = response data quote get('customtext c'); system assertequals('survives bundle pricing', textval); 4\ quotelineitem custom fields productinput does not have a built in mechanism for setting arbitrary custom fields on quotelineitem records if you need custom fields on line items, use a two step approach commit the quote first via ruby globalquoteserviceapi createquote() with iscommit = true query the created quotelineitem records and update them with custom field values via standard dml // step 1 create the quote request iscommit = true; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // step 2 update line items with custom fields list\<quotelineitem> lineitems = \[ select id from quotelineitem where quoteid = \ response data quote id ]; for (quotelineitem qli lineitems) { qli put('customlinefield c', 'custom value'); } update lineitems; note this gap means that custom line item fields require an additional dml operation after quote creation plan your governor limit budget accordingly key behaviors behavior details use put() for custom fields custom fields are not known at compile time and cannot be passed as constructor arguments always use put('fieldapiname', value) use put() for dynamic field references customer created custom fields (e g , customtext c ) are set via put() because they are referenced dynamically, not because of namespace nue package fields use the ruby prefix (e g , ruby subscriptionterm c ), but customer fields do not custom fields pass through pricing untouched the nue pricing engine does not modify or strip custom field values set on the quote header both modes preserve values custom fields are preserved in the response for both preview ( iscommit = false ) and commit ( iscommit = true ) modes bundle pricing is safe custom fields survive the full bundle expansion and pricing pipeline, including add on processing line item custom fields require post commit dml use the two step pattern described above to set custom fields on quotelineitem records
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.