Add JSON Type Company Parameter

When you use a Company Parameter of the JSON type, each parameter value is stored in a single DB field which has a structure of a Javascript object (JSON). In Pricefx this field is called attributeExtension. It allows you to add an unlimited number (in theory) of columns of any type and this way scale the project size over the time.

 Attribute Extensions are much slower and less efficient than native columns e.g. when filtering. Use them sparingly and cautiously!

  1. Go to Company Parameters and create a new one.

  2. Fill in the mandatory fields in the Company Parameter table.
    As Table Type select JSON; as Value Type select JSON or JSON2 depending on whether you want to have one or two key columns.

  3. Select the newly added Company Parameter and proceed to the right pane with Company Parameters Values.

  4. Click the table header and select Customize Attribute Extensions from the context menu.

  5. In the popup dialog create new columns. 

  6. Close the dialog. (Your entries will be saved.)

  7. To see the new columns in the Company Parameter Values table, click elsewhere in the table (e.g. a different Company Parameter). 

  8. Go back to your Company Parameter and the table on the right will be updated. 

  9. Add the Company Parameters values in the table. 


As mentioned above, all special columns are saved in one column called attributeExtension.

  • For the JSON table, the key is the column name

  • For JSON2, there are two keys key1 and key2.


Querying data is similar to a Company Parameter table. 


1 2 3 4 5 6 7 def filter = Filter.equal('name', key) def data = api.findLookupTableValues(<table_name>, filter) data.each {row -> row.attributeExtension___<name of special column1> //three underscores row.attributeExtension___<name of special column2> … }

In case of JSON2, there is a filter:

1 def filter = Filter.and(Filter.equal('key1', key1),Filter.equal('key2',key2)


Inserting values needs more steps. Since all special columns are saved into one, it is necessary to join them in a map first and save this map. 

To save one record:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 String key = 'my_key' //creates map where each attribute is name of the special column def attributeExtension = [ <name_of_special_column1> : <value1>, <name_of_special_column2> : <value2> ] //creates structure for the insert command, tableId is the ID of the JSON table – you need to find it out def req = [data: [ header: ['lookupTable', 'name', 'attributeExtension'], //for JSON2 use ['lookupTable', 'key1', 'key2', 'attributeExtension'] data : [[tableId, key, api.jsonEncode(attributeExtension)]] ]] //encodes the inserted structure def body = api.jsonEncode(req) def result = api.boundCall( 'customerA', //partition name '/loaddata/JLTV', //for JSON2 table it is JLTV2 body, true)