Example 4 - Dependent custom fields

Since version 5.8.0.x it is no longer required to have Power Scripts installed for the dependency feature to work! Power Custom Fields has grown up and can do it all by itself now.

 

To use the screen values for a field in the data source, add it as a dependent field

 

image-20240214-170838.png

 

Example

Let's say we have two custom fields: PCF - Single Autocomplete and PCF - Multiple Autocomplete, and the second field is populated depending on the value of the first one.

For instance, the first custom field has five options representing the five continents, and the second one contains the countries from the countries table, depending on the value selected in the Continent one. 

The following data source represents the first custom field: 

return {"AFRICA", "ASIA", "EUROPE", "AMERICA", "OCEANIA"};


The following data source represents the second custom field: 

string x = argv["customfield_10101"]; string[] res = sql("myDB", "select country from countries where continent like '" + x + "'"); return res;


The following result will be on the issue view screen: 



You can find a similar example here.

You can use the dependent fields in the single, multiple autocomplete fields.

Starting with Power Custom Fields 4.0.0, you can use the dependent fields on SQL data sources as well.

In order to get the value set on the screen for one custom field, refer it like this: "argv[customfield_id]"

 

See More