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
10 replies
Subscribers
5 subscribers
Views
8177 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
Trying to invoke an expression rule with input parameter from my java plugin.
girikumard
over 9 years ago
Trying to invoke an expression rule with input parameter from my java plugin.
Tried using evaluateExpression(java.lang.String expression, NamedTypedValue[] variableValues) method in ProcessDesignService Interface.But not able to construct variableValues of type NamedTypedValue[].
Do we have any sample code to pass a parameter to an expression rule from java ?
Thanks in Advance.
OriginalPostID-197077
OriginalPostID-197077
Discussion posts and replies are publicly visible
0
Rahul Gundu
over 9 years ago
Hi girikumar, i don't think it's possible to call Appian Expression rules, Appian functions from Java code.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sayedh
over 9 years ago
I think evaluateExpression should work. How are you constructing the NamedTypedValue? You should use the below constructor. Be sure to pass the parameter name and type. To determine type for an associated parameter, use the constants from AppianTypeLong.* (e.g. AppianTypeLong.STRING).
NamedTypedValue(java.lang.String name, java.lang.Long instanceType)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
abhi.jana
Appian Employee
over 9 years ago
Example using Appian's enumerate() function -
NamedTypedValue var = new NamedTypedValue();
var.setName("input");
var.setInstanceType(AppianTypeLong.INTEGER);
var.setValue(3);
List<NamedTypedValue> list = new ArrayList<NamedTypedValue>();
list.add(var);
NamedTypedValue[] inputs = new NamedTypedValue[list.size()];
list.toArray(inputs);
TypedValue result = new TypedValue();
try {
result = pds.evaluateExpression("=enumerate(!input)",inputs);
} catch (ExpressionEvaluationException e) {
e.printStackTrace();
}
System.out.println(result);
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
girikumard
over 9 years ago
@Abhi,
Above code is not working for me.
my expression rule "executeRule()" has one parameter of type integer. Tried the below piece of code but input is not getting passed.
LOG: Rule 'executerule' has 1 parameters, but instead passed 0 parameters.
Code:
NamedTypedValue var = new NamedTypedValue();
var.setName("pid");
var.setInstanceType(AppianTypeLong.INTEGER);
var.setValue(686);
List
list = new ArrayList
();
list.add(var);
NamedTypedValue[] inputs = new NamedTypedValue[list.size()];
list.toArray(inputs);
TypedValue result = new TypedValue();
try {
\tresult = pds.evaluateExpression("=executeRule()",inputs);
\t
} catch (Exception e) {
e.printStackTrace();
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
abhi.jana
Appian Employee
over 9 years ago
You should pass the input into the function -
result = pds.evaluateExpression("=executeRule(!pid)",inputs);
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
girikumard
over 9 years ago
Thanks Abhi.... It worked by passing the input
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rachelz585
over 9 years ago
@Abhi, Hi, I am doing the same syntax as above, but I am getting this error when I try to use evaluateExpression:
17:20:02,296 INFO [stdout] (http-/0.0.0.0:8080-33) 2016-03-30 17:20:02,294 [http-/0.0.0.0:8080-33] ERROR com.appiancorp.suiteapi.common.TypedValueParameterConverter - Cannot convert TypedValue
17:20:02,323 INFO [stdout] (http-/0.0.0.0:8080-33) java.lang.IllegalArgumentException: Argument is not an array
Do you know what could be the problem?
Thanks
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rachelz585
over 9 years ago
Also, the rule input is a text array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
abhi.jana
Appian Employee
over 9 years ago
It could be that the second argument of your evaluateExpression ("inputs" in the example) is not an array. Is it possible to paste your code (or the relevant bits) here?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rachelz585
over 9 years ago
i think it was because I was using a load and local variables in the rule that I passed to the plugin function I made. I modified the code and it works fine now!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel