Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Use case

Select a country or several countries In the Power Customer Fields example using countries and letters, you can select a letter in a custom field based on a continent country selected in another a different custom field.

Video

Widget Connectoroverlayyoutube_templatecom/atlassian/confluence/extra/widgetconnector/templates/youtube.vmwidth400pxurl

The following video has information about how dependent fields work.

https://wwwfast.youtubewistia.com/watch?v=NifKQWWjN9g&feature=youtu.beheight300px/embed/medias/aqj6ew4kki.jsonp

Script details

The options for the Continent Country custom field were taken from the database as well. The following scripts are used in this example:

Continent

Country data source

Code Block
string[] continents = sql("myDBreturn {"Romania", "France", "Norway", "select distinct continent from countries");
return continents;
Country
Spain"};

Letters data source

Code Block
string[] continentletters = argv["customfield_10109"];	//the dependent field
string[] countries = sql("myDB", "select country from countries where continent = '" + continent + "'");
return countries;
Note

For the moment, dependent fields can only be used by the two custom fields with autocomplete.

From Power Custom Fields PRO 4.0.0, you can now use the dependent fields on SQL data sources as well.

In order to get the value set on the screen for one custom field, reference it like this: "argv[customfield_id]".
{};
string cfname="Country";
for(int i=0; i<length(argv[cfname]); ++i) {
    letters += argv[cfname][i];
}
return letters;

See More

Child pages (Children Display)
pageExamples for PCF