How-to Guide
Nue Platform
Default Value Plugin
5 min
use case when creating a quote, the default values of the quote fields may be different for different scenarios for example, the quote template is determined by the account type, channel sales have a different quote template from the direct sales to support this case, you can add a default value plugin to implement the business logic via salesforce apex code implement plugin interface create an apex class and implement the quote default value plugin interface ruby custompluginmanager createquotedefaultvalueplugin the plugin returns the quote object which will be used to populate the default values on quote creation page note the apex class must be declared as ‘global’ since the interface is a global interface in the following plugin example, the quote template field will be automatically populated based on the account record type global class createquotedefaultvalueplugin implements ruby custompluginmanager createquotedefaultvalueplugin{ global quote getdefaultvalues(quote newquote){ system debug('newquote ' + newquote); // build quote template map map\<string, id> templatemap = new map\<string, id>(); list\<quote> quotetemplates = \[select id, name from quote where ruby is template quote c = true]; for(quote template quotetemplates){ if(template name == 'quote template for channel sales'){ templatemap put('channel', template id); } else if(template name == 'quote template for direct sales'){ templatemap put('sales', template id); } } // get quote related account info account acct = \[select id, name, recordtype name from account where id = \ newquote accountid]; if(relatedaccount != null){ // default the quote template based on the related account record type if(relatedaccount recordtype name == 'channel'){ newquote ruby template quote c = templatemap get('channel'); } else{ newquote ruby template quote c = templatemap get('sales'); } } //default the shipping and billing addresses to the shipping and billing addresses of the billing account associated account billingacct; account\[] billingaccounts = \[select id, name, billingstreet, billingcity, billingstate, billingcountry, billingpostalcode, shippingstreet, shippingcity, shippingstate, shippingcountry, shippingpostalcode from account where ruby salesaccount c = \ newquote accountid]; if ( billingaccounts size() > 0 ) { billingacct = billingaccounts\[0]; newquote ruby isshippingaddresssameasbilling c = false; newquote shippingstreet = billingacct shippingstreet; newquote shippingcity = billingacct shippingcity; newquote shippingstate = billingacct shippingstate; newquote shippingcountry = billingacct shippingcountry; newquote shippingpostalcode = billingacct billingpostalcode; newquote billingstreet = billingacct billingstreet; newquote billingcity = billingacct billingcity; newquote billingstate = billingacct billingstate; newquote billingcountry = billingacct billingcountry; newquote billingpostalcode = billingacct billingpostalcode; } else { system debug('this account has no billing accounts associated'); } return newquote; } } register plugin login to your salesforce org and in the system setting page search for ‘custom setting’ and go to the custom setting list page click on the ‘manage’ link on ‘nue system setting’ search for ‘createquotedefaultvalueplugin’ and click ‘edit’ in the edit page, add your apex class name to the value field and save the change now on the create quote page, the plugin will be executed before the page gets loaded, and all the fields’ values will be pre populated automatically additional notes the address type field is not supported for this plugin prior to release 2402
🤔
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.