rule-enginebusiness-rulescodeeffects

Codeffects RuleEngine: Method Datasource parameter with type string


I would like to ask you for your help with the definition of the method parameter.

I have this method definition:

[Method("Date from DataField")]
public DateTime DateTimeFromDataField([Parameter(DataSourceName = DataSourceHolders.InputTemplatesDataTreeSource, ValueInputType = ValueInputType.All)] string nodeKey) 
{
         /* some return code */ 
}

My problem is that I have the parameter with the datasource type string. This parameter is ignored. I found this part of your documentation:

DataSourceName Type : System.String Used only in rule action or in-rule method parameters that represent System.Int parameters of qualified .NET methods, and is ignored for parameters of other types. Gets or sets the unique name of the Dynamic Menu Data Source declared by the SourceAttribute on the source object. If set, the rule author can only select the value from the menu of items supplied by the data source method.

I would like to ask you whether there is other solution how to pass string value as datasource parameter ?


Solution

  • Code Effects rule editor doesn't support string IDs in menu data sources. You can always add auto-incrementing column to your table and use it instead of the string ID. That's the most common way to replace strings with integers.