Configuration Parameters
Configuration parameters are parameters used to initialize a query extension prior to any other interaction. This is typically used to select a table, entity, function or stored procedure from a list, which is then investigated to provide metadata and parameters.
While configuration parameters are very similar to query parameters, supporting different data types, domains, multi-select etc., there are some notable differences:
- Configuration parameters are always mandatory.
- Parameter operators are not supported.
- Configuration parameters cannot be linked to runtime parameters or Excel cells.
.
Enable the Configuration Parameters feature
To enable the Configuration Parameters feature, configure it in the extension .pyplugin or .netplugin header file:
Features=ConfigurationParameters
Configuration parameters are only supported for query extensions.
Implement the Configuration Parameters feature
A query extension requires configuration parameters by implementing the GetConfigurationParameters()
method.
def GetConfigurationParameters(self):
config = list()
rateTypes = list()
rateTypes.append(DomainItem(Value(DataType.string, "FX-RATE"), "FX-RATE"))
rateTypes.append(DomainItem(Value(DataType.string, "FX-VOLATILITY"), "FX-VOLATILITY"))
rateTypes.append(DomainItem(Value(DataType.string, "IR-RATE"), "IR-RATE"))
rateTypes.append(DomainItem(Value(DataType.string, "IR-VOLATILITY"), "IR-VOLATILITY"))
config.append(Parameter("rate_types", "Rate Types", DataType.string, None, rateTypes, True, "Select the rate types you want to query", True))
return config
protected override List<Plugin_Parameter> GetConfigurationParametersImpl()
{
var configParams = new List<Plugin_Parameter>
{
new Plugin_Parameter
{
Name = "rate_types",
Description = "Rate Types",
Type = Plugin_DataType.STRING,
Mandatory = true,
MultiSelect = true,
Domain = new List<Plugin_DomainItem>
{
new Plugin_DomainItem { ValueMember = new Plugin_Value("FX-RATE"), DisplayMember = "FX-RATE" },
new Plugin_DomainItem { ValueMember = new Plugin_Value("FX-VOLATILITY"), DisplayMember = "FX-VOLATILITY" },
new Plugin_DomainItem { ValueMember = new Plugin_Value("IR-RATE"), DisplayMember = "IR-RATE" },
new Plugin_DomainItem { ValueMember = new Plugin_Value("IR-VOLATILITY"), DisplayMember = "IR-VOLATILITY" },
}
},
};
return configParams;
}
GetConfigurationParameters()
follows the same pattern as GetParameters()
, returning a list of Parameter
objects.
Change the GetParameters()
implementation to accept an argument.
def GetParameters(self, configArgs):
# Create a reader for the configuration parameters
confReader = ArgumentReader(configArgs)
# Read the rate_types parameter. This is a multi-select parameter,
# so the user can select more than one type.
typeParam = confReader.GetArgument("rate_types").Value
rateTypes = list(typeParam.split(","))
protected override List<Plugin_Parameter> GetParametersImpl(List<Plugin_Argument> ConfigArgs)
{
var config = ConfigArgs.ToDictionary((p) => p.ParameterName);
var rateTypes = (config["rate_types"].Value as string).Split(',');
}
Configuration parameters are supplied to the GetMetadata()
and ExecuteQuery()
methods together with the query parameters.
def ExecuteQuery(self, arguments, columnSchema):
# Create a reader for the arguments.
# This includes also Configuration Parameters.
argReader = ArgumentReader(arguments)
# Preview count can be read from the ArgumentReader
# If this value is None, it is a full execution
previewCount = argReader.PreviewCount
# Configuration parameters are supplied together with query parameters,
# and can be read using the same argument reader.
rateTypes = list(argReader.GetArgument("rate_types").Value.split(","))
protected override Plugin_QueryResult ExecuteQueryImpl(List<Plugin_Argument> Parameters, Plugin_ColumnSchema ColumnSchema)
{
var paramLookup = Parameters.ToDictionary((x) => x.ParameterName);
var rateTypes = (paramLookup["rate_types"].Value as string).Split(',');
}
Since configuration parameters and query parameters are supplied to
GetMetadata()
andExecuteQuery()
in the same collection, you need to make sure the parameter names are unique. A configuration parameter and a query parameter cannot have the same name.
Updated 8 months ago