Variables
If a particular feature flag is enabled for a user, you can then fetch the required variables corresponding to that feature flag. These variables need to be first configured in VWO, and can then be fetched at your server and used to control the user's experience in your codebase.
getVariable()
// Get the variable value for the given variable key and default value
Object variableValue = featureFlag1.getVariable("int_variable_key", "default-value");
the getVariable() function requires just one argument, that is the 'int_variable_key' in the above example, which would be the unique key corresponding to a particular "Variable", as defined under Feature Flag > Variables.
Please note that the getVariable() function needs to be called on the feature flag object returned from the previous getFlag() function.
getVariable() returns the value of the specified variable :
- For testing rules, this value will depend on which variation the user becomes part of (for testing rules).
- For rollouts, this will return the default value of the variable.
- For personalise rules, it will return the appropriate value of the variable depending on what you have configured in the personalise rule in the FM&E application.
getVariables()
Similar to getVariable(), but this function returns an array of objects, with the values of all variables connected to a feature flag
// Returns the value of a single variable
Object variableValue = featureFlag.getVariable("stringVar", "default-value");
// Returns an array of all relevant variables and their values for a given feature flag
List<Map<String, Object>> allVariables = featureFlag.getVariables();
Updated 4 months ago