Set Up Initial Field Sets

This topic applies to

Applies to

SuiteCommerce | SuiteCommerce Advanced

Data from NetSuite, such as item information, is made available to your web store by defining a set of fields to expose. This section explains how to use a pre-defined script to quickly populate your site with required Field Sets. Use this field set setup script to get started.

Later, you can add fields specific for your business to this script or just accept the defaults to begin. For advanced field set overview and setup instructions, see Field Sets.

Warning

Do not delete field sets, as this may cause unintended results.


To set up the Field Set Setup script:

  1. Copy the contents of the Field Set Script below to a text editor.

  2. Edit the siteID variable with the site id you want to use.

    The site id is displayed in the URL when you navigate to the Web Site Setup page for the desired site.

    Note

    The default value of 9999 fails, since no site is ever assigned an ID of 9999.


  3. Set the configurable options as required.

    Each Field Set Setup Script includes a few options you can set. The default options add fields for using Product Reviews but not for Pickup In Store. Set the has_store_pickup flag to true if you intend to use Pickup In Store in your web store.

  4. Optionally, add any field set definitions as needed for your site.

    The script includes all required fields and provides a good starting point for your website.

    Important

    The Field Set to return item details is named details. If you decide to use a different name, you must configure that change as described in Items Fields Advanced Name on the Backend Subtab.


  5. Save your modified script.

    Your modified script can be used to quickly replicate a site setup during development.

  6. Execute the script in the SuiteScript debugger.

    1. Go to Customization > Scripting > Script Debugger.

    2. Enter the SuiteScript Debugger domain (by clicking the link as indicated) and then re-enter your login credentials if prompted.

    3. From the API Version dropdown, select 1.0.

      Important

      This script can only be run against SuiteScript Version 1.0.


    4. Copy and paste your modified script code into the debugger.

    5. Click Debug Script and then hit the Continue button.

After the script has executed, field sets are properly populated and can be verified in the Field Sets tab of the Web Site Setup record.

When you have completed this initial field set setup, you should now set up a rudimentary item search index for your web store. See Set Up a Initial Search Index.

Field Set Script

Note

If you have previously set up fields for your site, before running this script delete any field sets that are currently defined for the website where you want to run the script. Use caution when doing this as deleting field sets required for your site can have unintended results.


var siteID = 99999 // change to the site id you want to use , has_product_reviews = true , has_store_pickup = false , has_sale_units = false , siteRecord = nlapiLoadRecord('website', siteID); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Search'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'search'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var search_fields = 'urlcomponent,itemimages_detail,itemoptions_detail,internalid,matrixchilditems_detail,onlinecustomerprice,onlinecustomerprice_detail,onlinecustomerprice_formatted,onlinematrixpricerange,onlinematrixpricerange_formatted,quantityavailable,displayname,itemid,outofstockbehavior,outofstockmessage,stockdescription,storedescription,storedisplaythumbnail,storedisplayname2,isinstock,isbackorderable,ispurchasable,showoutofstockmessage'; if(has_product_reviews) { search_fields += ',custitem_ns_pr_count,custitem_ns_pr_rating'; } if(has_store_pickup) { search_fields += ',isstorepickupallowed,isfulfillable'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', search_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'details'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'details'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var details_fields = 'urlcomponent,itemimages_detail,itemoptions_detail,internalid,matrixchilditems_detail,onlinecustomerprice_detail,quantityavailable,displayname,itemtype,itemid,outofstockbehavior,outofstockmessage,pagetitle,rate,rate_formatted,relateditemsdescription,stockdescription,storedetaileddescription,storedisplayimage,storedisplayname2,isinstock,isbackorderable,ispurchasable,showoutofstockmessage,metataghtml,minimumquantity,maximumquantity'; if(has_product_reviews) { details_fields += ',custitem_ns_pr_count,custitem_ns_pr_rating,custitem_ns_pr_item_attributes,custitem_ns_pr_rating_by_rate'; } if(has_store_pickup) { details_fields += ',isfulfillable,isstorepickupallowed,quantityavailableforstorepickup_detail'; } if(has_sale_units) { details_fields += ',saleunit'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', details_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'matrixchilditems'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'matrixchilditems'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var matrix_fields = 'onlinecustomerprice_detail,internalid,quantityavailable,outofstockbehavior,outofstockmessage,stockdescription,isinstock,isbackorderable,ispurchasable,showoutofstockmessage,itemid,minimumquantity,maximumquantity,itemtype'; if(has_store_pickup) { matrix_fields += ',isfulfillable,isstorepickupallowed,quantityavailableforstorepickup_detail'; } if(has_sale_units) { matrix_fields += ',saleunit'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', matrix_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'matrixchilditems_search'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'matrixchilditems_search'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var matrix_fields = 'onlinecustomerprice_detail,internalid,outofstockbehavior,outofstockmessage,stockdescription,isinstock,isbackorderable,ispurchasable,showoutofstockmessage,itemid,minimumquantity,maximumquantity,itemtype'; if(has_store_pickup) { matrix_fields += ',isfulfillable,isstorepickupallowed,quantityavailableforstorepickup_detail'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', matrix_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Correlated Items'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'correlateditems'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var correlated_fields = 'urlcomponent,itemimages_detail,itemoptions_detail,internalid,onlinecustomerprice,onlinecustomerprice_detail,onlinecustomerprice_formatted,onlinematrixpricerange,onlinematrixpricerange_formatted,quantityavailable,displayname,itemid,outofstockbehavior,outofstockmessage,stockdescription,storedescription,storedisplaythumbnail,storedisplayname2,isinstock,isbackorderable,ispurchasable,showoutofstockmessage'; if(has_product_reviews) { correlated_fields += ',custitem_ns_pr_count,custitem_ns_pr_rating'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', correlated_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Related Items'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'relateditems'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var related_fields = 'urlcomponent,itemimages_detail,itemoptions_detail,internalid,onlinecustomerprice,onlinecustomerprice_detail,onlinecustomerprice_formatted,onlinematrixpricerange,onlinematrixpricerange_formatted,quantityavailable,displayname,itemid,outofstockbehavior,outofstockmessage,stockdescription,storedescription,storedisplaythumbnail,storedisplayname2,isinstock,isbackorderable,ispurchasable,showoutofstockmessage'; if(has_product_reviews) { related_fields += ',custitem_ns_pr_count,custitem_ns_pr_rating'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', related_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Order'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'order'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var order_fields = 'itemimages_detail,itemoptions_detail,onlinecustomerprice_detail,displayname,internalid,itemid,isfulfillable,storedisplayname2,urlcomponent,outofstockmessage,showoutofstockmessage,isinstock,isbackorderable,ispurchasable,pricelevel1,pricelevel1_formatted,stockdescription,matrixchilditems_detail,itemtype,minimumquantity,maximumquantity,isonline,isinactive'; if(has_store_pickup) { order_fields += ',isstorepickupallowed,quantityavailableforstorepickup_detail,isfulfillable'; } if(has_sale_units) { order_fields += ',saleunit'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', order_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Type Ahead'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'typeahead'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var typeahead_fields = 'itemid,displayname,storedisplayname2,urlcomponent,itemimages_detail'; if(has_product_reviews) { typeahead_fields += ',custitem_ns_pr_count,custitem_ns_pr_rating'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', typeahead_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Items Searcher'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'itemssearcher'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); var items_searcher_fields = 'itemimages_detail,displayname,itemid,storedisplayname2,urlcomponent,minimumquantity,maximumquantity,itemoptions_detail,matrixchilditems_detail,isinstock,showoutofstockmessage,outofstockmessage,onlinecustomerprice_detail,pricelevel1,pricelevel1_formatted,itemtype,ispurchasable,isbackorderable'; if(has_product_reviews) { items_searcher_fields += ',custitem_ns_pr_count,custitem_ns_pr_rating'; } siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', items_searcher_fields); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Related Items Details'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'relateditems_details'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', 'relateditems_detail'); siteRecord.commitLineItem('fieldset'); siteRecord.selectNewLineItem('fieldset'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', 'Correlated Items Details'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', 'correlateditems_details'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM'); siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', 'correlateditems_detail'); siteRecord.commitLineItem('fieldset'); recId = nlapiSubmitRecord(siteRecord);