Developer Resources
Create Quote & Create Order Gl...
Quantity Tier Attributes (QTA)
19 min
https //docs nue io/quantity tier attributes for price tags allow discount tiers to be resolved based on a field value rather than the line item's quantity for example, you can define discount tiers based on account numberofemployees (headcount buckets), so that larger organizations automatically receive deeper discounts how quantity tier attributes work in standard tiered pricing, the tier is determined by the line item's quantity with quantity tier attributes, the tier is determined by a mapped field — any field reachable from the quotelineitem via dot notation relationships resolution flow 1\ quantity tier attribute record defines a mapping path (e g , quotelineitem quote account numberofemployees) ↓ 2\ at pricing time, the engine resolves the field value (e g , account numberofemployees = 750) ↓ 3\ the value is matched against pricetier ranges (e g , 500 1000 = tier 3 = 7% discount) ↓ 4\ the matching tier's discount is applied as systemdiscount setup requirements quantity tier attributes require four configuration elements 1\ quantitypricetierattribute record a custom setting that defines the mapping from a line item field path to a value used for tier resolution // create a quantity tier attribute mapping for headcount based discounts ruby quantitypricetierattributeservice createquantitypricetierattribute createattr = new ruby quantitypricetierattributeservice createquantitypricetierattribute( 'numberofemployees', // name (unique key) 'number of employees', // label 'quotelineitem quote account numberofemployees' // mapping path ); createattr active = true; ruby quantitypricetierattributeservice attrservice = new ruby quantitypricetierattributeservice( new ruby databaseutils(), new ruby quantitypricetierattributeservicequery() ); attrservice createattributes( new list\<ruby quantitypricetierattributeservice createquantitypricetierattribute>{ createattr } ); 2\ pricedimension ( https //docs nue io/price and discount tags ) a ruby pricedimension c record of type discountdimension linked to the quantity tier attribute by name ruby pricedimension c pricedim = new ruby pricedimension c( name = 'headcount volume discount', ruby code c = 'regr disc headcount bucket', ruby pricedimensiontype c = 'quantity', ruby pricetype c = 'volume', ruby recordtype c = 'discountdimension', ruby active c = true, ruby quantitypricetierattribute c = 'numberofemployees' // links to the quantity tier attribute record ); insert pricedim; 3\ pricetier records define the tier ranges and their corresponding discount percentages // tier 1 0 100 employees = 0% discount ruby pricetier c tier1 = new ruby pricetier c( ruby pricedimension c = pricedim id, ruby startunit c = 0, ruby endunit c = 100, ruby amount c = 0, ruby tiernumber c = 1 ); // tier 2 100 500 employees = 3% discount ruby pricetier c tier2 = new ruby pricetier c( ruby pricedimension c = pricedim id, ruby startunit c = 100, ruby endunit c = 500, ruby amount c = 3, ruby tiernumber c = 2 ); // tier 3 500 1000 employees = 7% discount ruby pricetier c tier3 = new ruby pricetier c( ruby pricedimension c = pricedim id, ruby startunit c = 500, ruby endunit c = 1000, ruby amount c = 7, ruby tiernumber c = 3 ); // tier 4 1000+ employees = 12% discount ruby pricetier c tier4 = new ruby pricetier c( ruby pricedimension c = pricedim id, ruby startunit c = 1000, ruby endunit c = 999999, ruby amount c = 12, ruby tiernumber c = 4 ); insert new list\<ruby pricetier c>{ tier1, tier2, tier3, tier4 }; 4\ product attachment quantity tier attribute price dimensions can be applied in two ways explicit pass the price tag via productinput pricetags in the api request auto attached create a ruby productpricedimension c junction record linking the pricedimension to the product the tag is automatically applied when the junction's https //docs nue io/price books matches the opportunity's pricebook use case 1 quantity tier attribute on https //docs nue io/product bundle parent apply the headcount discount tag to a bundle parent with account numberofemployees = 750 , the engine resolves tier 3 (500 1000) for a 7% system discount // account numberofemployees = 750 account acc = \[select id from account where numberofemployees = 750 limit 1]; opportunity opp = \[select id from opportunity where accountid = \ acc id limit 1]; ruby globalapitypes createquoterequest request = new ruby globalapitypes createquoterequest(); request quote = new quote( opportunityid = opp id, name = 'quantity tier attribute bundle quote', pricebook2id = stdpricebookid, ruby subscriptionstartdate c = date today(), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month' ); request accountid = acc id; ruby globalapitypes productinput bundle = new ruby globalapitypes productinput(); bundle productsku = 'nue gem edition'; bundle uom = 'user/month'; bundle quantity = 10; // apply quantity tier attribute discount tag to the bundle parent ruby globalapitypes pricetaginput qtatag = new ruby globalapitypes pricetaginput(); qtatag code = 'regr disc headcount bucket'; bundle pricetags = new list\<ruby globalapitypes pricetaginput>{ qtatag }; request products = new list\<ruby globalapitypes productinput>{ bundle }; request iscommit = false; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // bundle parent has 7% system discount from quantity tier attribute quotelineitem parentqli = response data lineitems\[0] quotelineitem; system assertequals(7, parentqli ruby systemdiscount c); use case 2 quantity tier attribute on specific add on only apply the quantity tier attribute tag to a specific add on product within a bundle the bundle parent is unaffected ruby globalapitypes productinput bundle = new ruby globalapitypes productinput(); bundle productsku = 'nue gem edition'; bundle uom = 'user/month'; bundle quantity = 10; // apply quantity tier attribute only to the nue platform add on ruby globalapitypes productinput addon = new ruby globalapitypes productinput(); addon productsku = 'nue platform'; ruby globalapitypes pricetaginput qtatag = new ruby globalapitypes pricetaginput(); qtatag code = 'regr disc headcount bucket'; addon pricetags = new list\<ruby globalapitypes pricetaginput>{ qtatag }; bundle addons = new list\<ruby globalapitypes productinput>{ addon }; request products = new list\<ruby globalapitypes productinput>{ bundle }; request iscommit = false; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // nue platform add on has 7% system discount // bundle parent has 0% system discount (no tag applied) use case 3 quantity tier attribute on both parent and add on both the bundle parent and an add on can have the quantity tier attribute tag applied each resolves its tier independently based on the same account field value ruby globalapitypes productinput bundle = new ruby globalapitypes productinput(); bundle productsku = 'nue gem edition'; bundle uom = 'user/month'; bundle quantity = 10; // quantity tier attribute tag on parent ruby globalapitypes pricetaginput parenttag = new ruby globalapitypes pricetaginput(); parenttag code = 'regr disc headcount bucket'; bundle pricetags = new list\<ruby globalapitypes pricetaginput>{ parenttag }; // quantity tier attribute tag on add on ruby globalapitypes productinput addon = new ruby globalapitypes productinput(); addon productsku = 'nue platform'; ruby globalapitypes pricetaginput addontag = new ruby globalapitypes pricetaginput(); addontag code = 'regr disc headcount bucket'; addon pricetags = new list\<ruby globalapitypes pricetaginput>{ addontag }; bundle addons = new list\<ruby globalapitypes productinput>{ addon }; request products = new list\<ruby globalapitypes productinput>{ bundle }; request iscommit = false; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // both parent and add on have 7% system discount (750 employees → tier 3) use case 4 quantity tier attribute on nested bundle quantity tier attributes work on nested bundles (bundles containing other bundles) apply the tag to the outer bundle's parent product ruby globalapitypes productinput outerbundle = new ruby globalapitypes productinput(); outerbundle productsku = 'nue ultimate edition'; outerbundle uom = 'user/month'; outerbundle quantity = 10; // quantity tier attribute tag on the outer bundle parent ruby globalapitypes pricetaginput qtatag = new ruby globalapitypes pricetaginput(); qtatag code = 'regr disc headcount bucket'; outerbundle pricetags = new list\<ruby globalapitypes pricetaginput>{ qtatag }; request products = new list\<ruby globalapitypes productinput>{ outerbundle }; request iscommit = false; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); // outer bundle parent resolves quantity tier attribute tier from account numberofemployees use case 5 auto attached quantity tier attribute via productpricedimension junction when a ruby productpricedimension c junction record links a quantity tier attribute based pricedimension to a product, the tag is applied automatically without any pricetags input in the request // setup productpricedimension junction already exists for nue platform // linking it to the regr disc headcount bucket price dimension ruby globalapitypes productinput product = new ruby globalapitypes productinput(); product productsku = 'nue platform'; product uom = 'user/month'; product quantity = 10; // no pricetags needed — quantity tier attribute is auto attached via productpricedimension junction request products = new list\<ruby globalapitypes productinput>{ product }; request iscommit = false; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); quotelineitem qli = response data lineitems\[0] quotelineitem; // 7% system discount auto applied from quantity tier attribute (account numberofemployees = 750) system assertequals(7, qli ruby systemdiscount c); note auto attached tags only apply when the ruby productpricedimension c junction's pricebookentry matches the opportunity's pricebook use case 6 quantity tier attribute + discretionary discount stacking quantity tier attribute system discounts and discretionary discounts stack in a specific order listprice x quantity x term = listtotalprice \ systemdiscountamount (from quantity tier attribute tag) = subtotal \ discountamount (discretionary) = totalprice the quantity tier attribute discount is applied first as a system discount then the discretionary discount is applied to the resulting subtotal ruby globalapitypes productinput product = new ruby globalapitypes productinput(); product productsku = 'nue platform'; product uom = 'user/month'; product quantity = 10; product discount = 10; // 10% discretionary discount // apply quantity tier attribute tag (7% system discount from headcount tier) ruby globalapitypes pricetaginput qtatag = new ruby globalapitypes pricetaginput(); qtatag code = 'regr disc headcount bucket'; product pricetags = new list\<ruby globalapitypes pricetaginput>{ qtatag }; request products = new list\<ruby globalapitypes productinput>{ product }; request iscommit = false; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); quotelineitem qli = response data lineitems\[0] quotelineitem; // example calculation (assuming listprice = $9 90, qty = 10, term = 12) // listtotalprice = $9 90 x 10 x 12 = $1,188 00 // systemdiscount = 7% = $83 16 // subtotal = $1,188 00 $83 16 = $1,104 84 // discretionary = 10% of $1,104 84 = $110 48 // totalprice = $1,104 84 $110 48 = $994 36 system assertequals(7, qli ruby systemdiscount c); // quantity tier attribute tag discount system assertnotequals(0, qli ruby discountamount c); // discretionary discount applied separately key behaviors behavior details runtime field resolution the quantity tier attribute mapping path (e g , quotelineitem quote account numberofemployees ) is resolved at runtime to determine the tier systemdiscount vs discount quantity tier attribute discounts appear in ruby systemdiscount c / ruby systemdiscountamount c discretionary discounts appear separately in ruby discount c / ruby discountamount c independent per line each line item with a quantity tier attribute tag resolves its tier independently auto attached via junction ruby productpricedimension c records can auto apply quantity tier attribute tags when the junction price book entry matches the opportunity's pricebook explicit via pricetags apply quantity tier attribute tags explicitly using productinput pricetags with the pricedimension's ruby code c or id stacking order system discount (quantity tier attribute) is applied first to produce subtotal, then discretionary discount produces totalprice inactive quantity tier attribute records inactive ruby quantitypricetierattribute c records that reference deleted fields can cause "mapping fields are required" errors remove obsolete inactive records to avoid this
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.