1. Tony Fahlberg
  2. SnapDevelop
  3. Thursday, 20 February 2020 20:03 PM UTC

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,

Accepted Answer
Tony Fahlberg Accepted Answer Pending Moderation
  1. Thursday, 20 February 2020 22:19 PM UTC
  2. SnapDevelop
  3. # Permalink

Hi - I opened BUG 4137 after receiving a similar error with a non-custom function (lower) when evaluating an expression on a NULL column.  If you believe these issues are related please let me know and I will close out this question. 

Otherwise, I look forward to hearing your response.  - Thank you

Comment
  1. Chris Pollach @Appeon
  2. Friday, 21 February 2020 15:58 PM UTC
Hi Tony ... one of our SNAP support people is now trying to recreate your ticket #4137 issue. Stay tuned. ;-)
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.