Placeholder Color Logic
This tutorial allows you to dynamically define a name for an Item Option using the name
of the Colors assigned to them via object reference. Assuming a Family Item named "Shirt" with Item Options, each Option's optionName
property will be derived from the associated Color. On Color updates, optionName
will change dynamically based on the Color name
, else fallback to the placeholderColor
property.
This can be achieved with Formulas and properties defined on both the Plan Placeholder and Item entities.
Property Setup¶
The first step is to create a series of properties that will allow you to define the logic (the names of properties used in this tutorial are merely suggestions, feel free to adapt the names to your particular needs):
created_by_data_load
¶
This is an "All"
level boolean property. If you are loading items using the loader, you might want to keep the already defined optionName from the CSV file. This property can be used to keep this optionName
provided you set it to true in the CSV load file.
color_name
¶
This is an Option level "object-reference"
property. Usually a property like this will reference the color assigned to each option.
placeholder_color
¶
This is an Option level "string"
property. The purpose of this property is to hold some value that could serve as a placeholder for your option name in case the previous two conditions don't apply. This would be the default value.
Formula Setup¶
Once you have created the corresponding properties, you will need to set up the complete formula in the optionName
property like so:
if (obj?.created_by_data_load === 'Yes') {
return obj.optionName;
} else if (obj?.color_name){
return obj.color_name.name;
} else {
return obj.placeholder_color;
}
End Result¶
If the Item Option was created by a data load, the value loaded into optionName
will take priority. Otherwise, if the Option has a color_name
object reference, that Color.name
will be used as the Option's optionName
. Finally, if none of these conditions apply, the placeholder_color
value will be used.