Hi I need to evaluate an expression rule from my smart service. I cou

Hi

I need to evaluate an expression rule from my smart service. I could able to get the expression rule id through ContentService.searchByRoot(rulesRootId, ruleName, filter)
and I got an object of type FreeformRule and i can get the expression rule id from that object.
I need to evaluate this rule and get the results which return a custom data type.

I tried to use ExpressionService.evaluateExpression, but it is deprecated method. In processDesignService.evaluateExpression takes java.lang.String Expression as parameter, not expression rule id.
Please suggest me with suitable api that takes expression rule id as parameter and return results
Thanks
Jhothi

OriginalPostID-141185

OriginalPostID-141185

  Discussion posts and replies are publicly visible

  • Hi Jhothi, any reason why you can evaluate the expression prior to calling the plugin? Usually, you want to stay away from having a dependency on an expression rule within the plugin. I would suggest that you pass-in whatever the plugin needs as input and then have the plugin do its work and then set the output.
  • 0
    Certified Lead Developer
    You can use evaluateExpression API available in ProcessDesignService class
  • 0
    Certified Lead Developer
    Pl ignore. I see that you already tried ProcessDesignService.evaluateExpression
  • ProcessDesignService.evaluateExpression works fine, simply build the expression as a string instead of using ContentService.searchByRoot, for example:

    pds.evaluateExpression("=ruleMyRule()")
  • Hi

    Thanks for all suggestions.

    Will it not be possible to evaluate expression rule that returns custom data type from Smart service / Filter code?

    I need to evaluate an expression rule inside Filter class, so i can not pass it as process parameter. So I created the below expression rule named EI_TESTRULE with rule definition:
    ='type!{bac.com/entitlement/AppianGroup}AppianGroupConfig'(
              appianApplicationName: "Test",
              appianGroupName: "Test",
              appianParentGroupName: "Test",
              appianCustomGroupType: "Test",
              appianGroupSecurityType: "Test",
              appianGroupMemberPolicyType: "Test",
              appianGroupPrivacyPolicyType: "Test"
    )
    and it worked when i tested it from Appian designer portal.

    I have imported this package to my filter (it got imported as com.bac.entitlement.AppianGroup.AppianGroupConfig.java class).
    and I tried to get this expression rule evaluated in my filter class using the below code:

    ProcessDesignService pds = getProcessDesignService();
    TypedValue tv1 = pds.evaluateExpression("=EI_TESTRULE()");

    When i execute the filter code, i got the below error:
    com.appiancorp.process.expression.ExpressionRuntimeException$AppianExceptionProvider: Expression evaluation error : Rule ei_appiangroupconfig_constant has invalid form, so cannot be evaluated (APNX-1-4198-000)


    Please help
    Thanks
    Jhothi





  • There are a lot of examples in the Shared Components of custom functions and smart services that use Complex Data Types, you don't need to evaluate an expression, you simply import the complex data type as a POJO into your Appian Java Project and you build the instance of the data type as any Java object.

    Useful links:

    forum.appian.com/.../Defining_a_Custom_Data_Type.html
    forum.appian.com/.../summary
    forum.appian.com/.../summary

    As you can see in those examples there is no need to evaluate an expression to build your Complex Data Type.
  • Thanks Ed for your suggestions. I have imported the complex data type already. My project requirement is to read the values of a complex data type set in Appian from Authentication Filter. I am using this filter for customizations at the time of user login. Since there is no way in a filter to read user input values, I have created an expression rule in Appian Rules tab which when evaluated returns a custom data type ( with values set) and I want those values to be read from filter.
    I used ProcessDesignService.evaluateExpression but I got the error:
    com.appiancorp.process.expression.ExpressionRuntimeException$AppianExceptionProvider: Expression evaluation error : Rule ei_appiangroupconfig_constant has invalid form, so cannot be evaluated (APNX-1-4198-000)
    Pds.evaluateExpression works if the expression rule returns a TEXT data type, but DOES NOT WORK when the rule returns a complex CDT object.
    Is there a way to read a CDT object values from Java (Filter / Smart services)?
    Thanks
    Jhothi