Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
21 replies
Subscribers
7 subscribers
Views
8583 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I am having problems writing an expression rule that uses displayvalue() functio
briank538
over 8 years ago
I am having problems writing an expression rule that uses displayvalue() function.
I have an array CDT called BusinessRulesCDT. It keeps erroring out complaining about the 4th argument to displayvalue() which is the default value.
At run time, it gives the error message:
Details: ERROR:An error occurred while evaluating expression: businessRule:rule!findBusinessRuleCDT(pv!businessRuleArray, pv!ruleName,pv!defaultBusinessRule) (Expression evaluation error in rule 'findbusinessrulecdt' at function 'displayvalue' parameter 4: ) (Data Outputs)
My BusinessRuleCDT is:
- id (integer)
- name (text)
- value (text)
my expression rule is:
findBusinessRuleCDT(businessRuleArray (Any Type), ruleName (Text), defaultBusinessRule (Any Type))
which calls ==> displayvalue(ri!ruleName, ri!businessRuleArray.name, ri!businessRuleArray, ri!defaultBusinessRule)
For the 4th parameter, I tried {}, "", and even the example above where I pass ...
OriginalPostID-170427
OriginalPostID-170427
Discussion posts and replies are publicly visible
0
briank538
over 8 years ago
The "fn!" infront of the displayvalue() call inside an expression rule did not work either. Same error about the 4th argument.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@briank Could you please try the below definition for rule!findBusinessRuleCDT()?
fn!displayvalue(ri!ruleName, ri!businessRuleArray.busrules_name, ri!businessRuleArray, null)
Also as already asked, would you be able to reproduce the logs at the time when you are experiencing the error?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
briank538
over 8 years ago
Same error. I've attached the application server log relating to the error. Thanks.
error-log-entry.txt
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@briank So if we keenly observe the 'Caused by' in logs that suggests the issue some times. As per the logs attached by you, accessing an invalid field in cdt is causing the issue.
Caused by: java.lang.IllegalArgumentException: Invalid index: Cannot index property 'busrules_name' of type Text into type PRQ_Config_BusRules?list
Now if we take a look at the cdt structure, busrule_name exists but busrules_name doesn't exist. So please correct the definition of displayvalue() in findBusinessRulesCDT rule accordingly, 2nd parameter is wrong here. And one more correction I would like to make here is, earlier you said that the same worked in process but it's not true I guess. As you refer the column from the PV, you might not have made a mistake. But in the rule, you are manually including the column name and so there has been a mistake which is causing the rule to fail.
Please try the above suggestion and do let us know if you have any follow up questions or issues.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
briank538
over 8 years ago
Well, we have a chicken and the egg problem then.
In defining the input parameters to the expression rule, I can't set the types to my own CDT. It doesn't show up. Only the System Types. The only thing I can possibly set it to is Any Type.
So, how I am supposed to get around that?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
Well I meant to say that you need to update the definition of the rule!findBusinesRulesCDT() as follows:
fn!displayvalue(ri!ruleName,ri!businessRuleArray.busrule_name,ri!businessRuleArray,ri!defaultBusinessRule)
And yes you can't have your own type for the data type of the input(in expression rules I guess), and therefore you need to carefully configure the column which you are going to make use of. Anyhow the logs and alerts are there for us to let us know the issues.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
briank538
over 8 years ago
My expression body already looks like that.
So, in essence, I can't use displayvalue() inside an expression rule when passing my own CDT types because I'll get the type mismatching error resulting in what looks like bad 4th argument to displayvalue(). That mean's I'll always have to rely on script tasks to search through a CDT typed array variable. Do you have any java plug-in source code examples of searching or looping through a CDT array typed pv? It looks like I may have to resort to that.
Would it be possible for Appian to incorporate same logic into the expression rule as you do in the SAIL forms? That way I can do exactly what I am trying to do here. In SAIL forms, you can declare a parameter as Any Type and pass in your own CDT typed pv's and at run time it figures it out type when dereferencing a member of the CDT parameter. That would open up so much more functionality and make expression rules even more useful. I hope Appian would consider this.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@briank I would like to say that your expression body exactly doesn't already look like that. So the definition of findBusinessRuleCDT rule which you have created is as follows:
fn!displayvalue(ri!ruleName,ri!businessRuleArray.busrules_name,ri!businessRuleArray,ri!defaultBusinessRule)
Here if you see the second argument of displayvalue(), you are using an inexistent field, namely 'busrules_name' in cdt. Even the logs are suggesting the same.
The suggestion which I have made is as follows after correction of busrules_name to busrule_name in second argument of displayvalue() in findBusinessRuleCDT rule:
fn!displayvalue(ri!ruleName,ri!businessRuleArray.busrule_name,ri!businessRuleArray,ri!defaultBusinessRule)
I would like to suggest to proceed with conclusions after the correction of error in current implementation.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
briank538
over 8 years ago
Thanks Sikhivahans. That took care of the problem. And I returned "null" (without quotes) in the default value parameter and it worked fine.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@briank Great, the reason why I suggested using the null as default value instead of "" or {} is, it's not the right way to store "" or {} into the cdt variable. Also now you could try to return the cdt as a default value if needed, as the error is resolved.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
<
>