Skip to end of banner
Go to start of banner

Example 1 - Working with huge Data Sets

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

<ac:layout><ac:layout-section ac:type="two_right_sidebar" ac:breakout-mode="default"><ac:layout-cell>

Required apps

  • Power Custom Fields PRO™ or
  • Power Custom Fields


Huge data sets

Let's say you have a business selling car parts and of course you have thousands of products and have to work with huge data sets. Power Custom Fields™ helps you save your time tremendously because you no longer need to go through the list of all products to select the necessary one. 

The app enables you to intervene in the process of data build-up even in the stages of the autocomplete. You can see this in the picture below: 

Considering we have a PCF - Multi Select custom field configured with one SIL™ Data Source, one Selection script, minimum characters for autocomplete set to 5, the maximum results number set to 50 and the filtering strategy set to "DataSource". We want to select from our big data set the items using the ids they have.


For this example we used the following SIL data source.

string s = argv["query"];
KPOption [] res;
if(length(s) > 2) {
    KPOption[] options = sql("myDB", "select name, id from car_parts where id like '%" + s + "%' limit 100" );
    for (int r = 0; r < size(options); r++) {
        if (contains(options[r].value, s)) {
         	res = addElementIfNotExist(res, options[r]);
        }
    }
 }
 return res;

In the script above,

  • myDB represents the resource name of the data base used, 
  • car_parts represent the table from the data base we want to select from
  • ("name", "id") are the columns converted to an object of the KPOption type and represented by a pair (label, value). 

If you use this script as data source, your custom field will be populated like this: 

We can use a select script to do certain things when an item from the autocompleted list is selected.  

KPOption[] selectedOptions = customfield_12101;
description += "You have selected the next item: " + selectedOptions[size(selectedOptions)-1].label + 
               "; " + selectedOptions[size(selectedOptions)-1].value + "\n ";

The example above sets the description like this: 

See also

</ac:layout-cell><ac:layout-cell><p><strong>See More</strong></p><ac:structured-macro ac:name="children" ac:schema-version="2" data-layout="default"><ac:parameter ac:name="page"><ac:link><ri:page ri:content-title="Examples for PCF" ri:version-at-save="2" /></ac:link></ac:parameter></ac:structured-macro></ac:layout-cell></ac:layout-section></ac:layout>

  • No labels