Example 1 - Working with huge Data Sets

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