Hi - I am using DwFunctionManager.AddGlobalFunction<TClass>() to inject a class which contains custom PB functions (static methods). I am then using my function in an expression when using IDataStore.Evaluate(). I am having an issue when my string column is null. If the string column has a value the fxn works. For example...
My static function in my class:
public static string AddPrefix(string value)
{
string retVal = string.Empty;
if (!string.IsNullOrEmpty(value)) retVal = "Mr. " + value;
return retVal;
}
Using fxn in expression:
IDataStore.Evaluate("AddPrefix(colName)",0);
When the column is null it does not appear to find the fxn maybe due to a different datatype expected in the param? The error message states:
System.NotSupportedException
HResult=0x80131515
Message=Method: addprefix
Source=SnapObjects.Data
StackTrace:
at SnapObjects.Expressions.EvaluatePolicyProvider.TryInvokeMethod(String name, Object args, ParserOptions`1 options, Object& result)
...
Any suggestions on how I can get this global fxn to work if my string column is null as well as when it has data without having to check for null in my expression. I am OK with creating a 2nd fxn with a different param to return empty string if the column is null (if necessary). I am asking because I have clients which create their own expressions using pre-defined global PowerBuilder fxns that my company has created. I am evaluating creating a C# library or Web API with these new tools and cannot expect clients to change their existing expressions.
Thanks,