Saturday, February 16, 2019

Sourcing URL Component in a Transaction Column Field through Script

 

Sourcing URL Component from the Item record > Web Store tab > Search Engine and Feeds field group.

The field is only available if the 'Descriptive URLs' feature is enabled in Setup > Company > Enable Features > Web Presence

 

I. Create a Custom Field

 

1. Navigate to  Customization > Lists, Records, & Fields > Transaction Column Field > New.

2. Add a Label for the field.

3. Store Value is checked.

4. Select Text Area for Type.

5. Check Sales Item in the Applies To tab.

6. Save the field.

 

II. Create a Client Side Script

 

1. Create a script with the following code

 

function clientValidateLine(type) {

 

var item = nlapiGetCurrentLineItemValue('item', 'item'); // Get the item ID of the selected line item

var url = nlapiLookupField('item', item, 'urlcomponent'); //Get the value URL Component of the item

 

var itemurl = nlapiSetCurrentLineItemValue('item','custcol_one', url); // item , internal ID of the ustom transaction column field, url

 

return true;

}

2. Save as SourceURLComponent.js.

3. Upload the script to NetSuite's File Cabinet under Documents > Files > SuiteScript. Click Add File.

4. Once the Open window has appeared, select SourceURLComponent.js.

5. Click Open to save the file in the File Cabinet.

6. Navigate to  Customization > Scripting > Scripts > New.

7. Select Client in the selection.

8. In the New Script window, add a Name.

9. Select the SourceURLComponent.js under Script File.

10. Add the 'clientValidateLine' under the Validate Line Function

11. Click Save and Deploy.

12. Select your Estimates under the Applies To tab. 

13. Set status to Release.

14. Add an audience.

15. Click Save.

 

Note: Since the script is set to a Validate Line Function, users need to add a line item on the transaction for it to trigger.

No comments:

Post a Comment