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
7 replies
Subscribers
5 subscribers
Views
3605 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
We have created plug-in to write custom function in appian called as fn!mydataap
sridharj
over 9 years ago
We have created plug-in to write custom function in appian called as fn!mydataappend and it accepts input param as Emplyee (CDT). After we deployed into appin we are able to see the custom function but when we call the function in appian we are getting below error. Could you please suggest what is the reason for that and solution.
Caused by: com.appiancorp.suiteapi.common.exceptions.AppianException: Unable to find a required instance of Employee. (APNX-1-4158-006)
at com.appiancorp.process.expression.CustomFunction.evaluate(CustomFunction.java:597)
at com.appiancorp.process.expression.CustomFunction.evalDynamic(CustomFunction.java:197)
at com.appiancorp.process.expression.CustomFunction.eval0(CustomFunction.java:188)
at com.appiancorp.core.expr.Evaluable.eval(Evaluable.java:213)
at com.appiancorp.process.expression.ExpressionEvaluator.evaluate(ExpressionEvaluator.java:295)
at com.appiancorp.core.expr.AppianScriptContextTop.evalExternalFunction(Appi...
OriginalPostID-186615
OriginalPostID-186615
Discussion posts and replies are publicly visible
0
sridharj
over 9 years ago
...anScriptContextTop.java:428)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rawich
over 9 years ago
Hi Sridhar, you might want to share your SAIL code invoking this function. It looks like the error happened just right before your code get executed. The issue is probably with how you pass the Employee CDT to the function.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rishub356
over 9 years ago
with(
local!employeeData: {
firstName: "A",
middleName: "B",
lastName: "V"
},
fn!mydataappend(
local!employeeData
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rishub356
over 9 years ago
Hey rawichp236, Please find the sail code above. Thanks.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rawich
over 9 years ago
Two main things here:
1) You have to create your customer function as Writer function:
forum.appian.com/.../Custom_Function_Plug-ins.html
The first sentence in the section of document will tell you that a normal function should not modify data, because expression evaluation can happen multiple times, and you have no absolute control of how often, and when.
Once you created the function plug-in as Writer function, then you'll make a call to this function from within a bind(), which is within a load() functions.
2) The error you received was because your function got evaluated before the emplyeeData is properly defined. It's hard to tell, and we have no control of which part of with() function got evaluated first. But once you modify your function to be a Writer function, and do the call via a bind that tie to a user action (such as button clicked), then you won't have this issue.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rawich
over 9 years ago
I meant to say,
1) You have to create your custom function as a Writer function...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rishub356
over 9 years ago
Thx Rawichp
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel