Question
· Oct 29, 2021

Calling a Function from the WHEN directive in a Business Rule specification

In specifying a "WHEN" condition statement, I don't seem to be able call a function directly from this declaration, as the generator seems to get confused

In the graphical editor:

%request.GetValue("MRN"))=123453

(%request.GetValue("MRN"))=123453)

In the DTL directly: 

<when condition="(%request.GetValue(&quot;MRN&quot;))=123453)">

<when condition="(%request.GetValue&#40;&quot;MRN&quot;&#41;)=123453)">

 

But they all fail at the same point, where the opening "(" of the method call completely confuses the generator, and these all throw the same error:

ErrParsingExpression: Error parsing expression '(%request.GetValue("MRN"))=123453)': ERROR <Ens>ErrInvalidToken: Invalid token at offset 19

 

The request class type DOES have an instance method called GetValue() that takes a single string parameter

The ultimate int code I'm trying to generate should look something like this:

((pContext.%request.GetValue("MRN"))=(123453))

Which SHOULD be ok.

My question is, is there any syntax for making a function call in the WHEN clause?

Product version: IRIS 2021.1
Discussion (2)2
Log in or sign up to continue

Hi Chip,

I believe you need to create a function that extends Ens.Rule.FunctionSet which should then give you the option to select this function within the UI or for usage within the DTL as well depending on your preference of course.  Let me see if I can find an example for you.  Note: I simplified my code to fit closer to your ask, but I did not test it.

Thanks,

Chris

Appendix)

Figure 1) SimplePid3Filter Function call within when clause

Figure 2) SimplePid3Filter function being called via DTL where the return type is As %String (clipped from screenshot)

Good answer. If I may add.

You can't use Output or ByRef arguments on these functions, or let me rather say that I have not gotten it to work.

What you can do is return a collection type property, or you can pass in the context as a parameter to set properties on the context.
If you are wondering how to reference a context in a ruleset, add a property to you context of type %RegisteredObject and call it something like RefToSelf. Set the property to the OREF of the context once the context has been created.
Then in the rulefunction call, you pass in RefToSelf.