We have created plug-in to write custom function in appian called as fn!mydataap

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

Parents
  • 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.
Reply
  • 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.
Children
No Data