Dependencies between Connect custom fields
Based on the previous example, let's see how we can configure it using dependencies between 2 (or more) fields.
Remember, we need to configure 4 fields:
- Continent (ID 10001)
- Value fetched using REST API
- Country (ID 10002), based on the selected continent,
- Value fetched using REST API
- Car (ID 10003), based on the car types available in the selected country
- Value stored in a database
- Model (ID 10004), based on the car type
- Value stored in a database
Configuration
Continent
This is the parent field, it doesn't contain any dependencies and is just going to fetch a list of every continent.
User should select one.
Continent query - REST API
{BaseURL}/continents
Country
Country depends on the value selected in the Continent custom field.
Country query - REST API
{BaseURL}/countries?continent='$issue.customfield_10001'
Car
Car depends on the selected country. Yes, depending on the country you're in, cars sold aren't the same!
Car query - database
SELECT car
FROM car_catalog
WHERE country ='$issue.customfield_10002'
Model
Model depends on the car, where the engine or the embedded software can differ
Model query - database
SELECT model
FROM car_models
WHERE car ='$issue.customfield_10003'
Warning for object type fields
For all object-type fields, we recommend you specify in the dependency which attribute is to be used.
If you don't, then the id attribute will be used.
If customfield_10097 is type Object; with:
"customfield_10097": {"id": "LG","value": "nom: LG"},
Then:
SELECT "Cell_phones"."salePrice", "Cell_phones"."name", "Cell_phones"."color"
FROM "Cell_phones"
WHERE "Cell_phones"."name" = '$issue.customfield_10097'
will retrieve "LG"