Scenario
There are instances when an account have a long list of available shipping method, though there are only several methods that are usually used.
In this type of scenario, the user may wish to limit the shipping methods that they see in the list.
Solution
Since the list set on the Shipping Method field could not be directly limited, one can make use of the alternate solution below:
-
Create a custom list via Customization > Lists, Records, & Fields > Lists > New
-
- Name: <desired name>
- Values > Value: <Name of the desired shipping method>
-
Create a custom transaction field via Customization > Lists, Records, & Fields > Transaction Body Fields > New
-
- Label: <desired name>
- Type: List/Record
- List/Record: <list in step 1>
- Applies To: Sales
-
Display tab:
- Subtab: Shipping
- Display Type: Normal
- Store Value: checked
-
Create a Client side script triggered on field change
//set the actual shipping method based on the selected value from the custom list define(['N/record'], function(record) { function fieldChanged(scriptContext) { log.debug('name', scriptContext.fieldId); if (scriptContext.fieldId == 'custbody24') // custbody24 is the internal ID of the field in step 2 { var custMethod = record.getValue({ fieldId: 'custbody24' }); log.debug('custMethod', custMethod); var shipMethod; if (custMethod == '1') // if - else was used since switch is not working { shipMethod = '1465'; // internal ID of the shipping method } else if (custMethod == '2') { shipMethod = '248'; } log.debug('shipMethod', shipMethod); record.setValue({ fieldId: 'shipmethod', value: shipMethod, ignoreFieldChange: false }); } } return { fieldChanged: fieldChanged }; });
SuiteScript 1.0:
function clientFieldChanged(type, name, linenum) { nlapiLogExecution('debug', 'name', name); if (name == 'custbody24') // custbody24 is the internal ID of the field in step 2 { var custMethod = nlapiGetFieldValue('custbody24'); nlapiLogExecution('debug', 'custMethod', custMethod); var shipMethod; if (custMethod == '1') // if - else was used since switch is not working { shipMethod = '1465'; // internal ID of the shipping method } else if (custMethod == '2') { shipMethod = '248'; } nlapiLogExecution('debug', 'shipMethod', shipMethod); nlapiSetFieldValue('shipmethod', shipMethod, false); } }
-
Set the Ship Method display type to Inline Text
- Custom Transaction Form > Screen Fields subtab > Shipping sub subtab > Shipping Method
- Display Type = Inline Text
Disclaimer
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.