# HCL Digital Experience Portlet Preference Script Application sample

This sample shows the use of Preference JavaScript API within a Script Application. 

The data that is read from a JSON file is displayed as a table. The columns that are displayed in the table are controlled by preference values that are stored in the portlets preferences. 

This allows a user to use the same portlet to display different data depending on the preferences that are set for that instance of the portlet. 

For this sample, the preferences are an array of strings that indicate weather a column is visible or not. 

The Preference API supports the setting different kinds of preferences from simple strings, JavaScript arrays or JSON objects, it is up to you to identify the type of data your portlet or application needs. 

Every Script Application can have preferences as needed and the preference definition can be customized to the specific instance.

This sample also has a more complex example of using the Script Portlet namespace tag \_\_SPNS\_\_. Using this tag helps you make sure your Script Application is independent of other Script Applications and portlets or multiple instances of the same application on a page. It can be used in your HTML for making sure your id's are unique, in your CSS if you are using selectors that are based on an item id and in your JavaScript to make sure your functions and data are uniquely named to prevent collisions.

Use the [HCLSoftware U HDX-DEV-200 Script Application lesson](https://hclsoftwareu.hcltechsw.com/component/axs/?view=sso_config&id=3&forward=https%3A%2F%2Fhclsoftwareu.hcltechsw.com%2Fcourses%2Flesson%2F%3Fid%3D3655) to learn how to use this. This is part of the free [HCLSoftware U HDX-DEV-200 HCL Digital Experience Portlet Development course](https://hclsoftwareu.hcltechsw.com/courses/course/hdx-dev-200-dx-developer-intermediate).
