Skip to main content
alphar0001
August 16, 2021
Solved

Executing a rule whose name is saved in a DB column from Process Model Script Node's Expression

  • August 16, 2021
  • 4 replies
  • 0 views

Rule name is available (retrieved from DB ) in as pv!integration.mappingRule.I am trying to run this rule in Node output expression rule

I have tried various options like

rule!pv!integration.mappingRule

or

rule!eval(pv!integration.mappingRule)

or

eval(rule!pv!integration.mappingRule )

None of them works .  Any idea , how to make this work? Thanks in advance.

Best answer by peter.lewis

Your best bet is to create a mapping rule in Appian that calls the rule that corresponds to whatever text value you store in the database. For instance:

choose(
  wherecontains(
    ri!ruleName,
    {"ruleOne", "ruleTwo", "ruleThree"}
  ),
  rule!ruleOne,
  rule!ruleTwo,
  rule!ruleThree
)

Please do not use the eval function - it is undocumented, unsupported, and is not guaranteed to behave in the manner you want or expect.

4 replies

stefanhelzle0001
Brainy
August 16, 2021

May I ask what you want to achieve?

BTW, eval() is a not supported private function and should not be used.

alphar0001
August 16, 2021

Thanks Stefan Helzle, I am aware that eval is an internal function. I couldn't find another way though. We are trying to execute dynamic rules here. This implementation supports number of countries with each country has a different mapping rule. Hope that makes sense.

peter.lewis
Employee
August 16, 2021

Your best bet is to create a mapping rule in Appian that calls the rule that corresponds to whatever text value you store in the database. For instance:

choose(
  wherecontains(
    ri!ruleName,
    {"ruleOne", "ruleTwo", "ruleThree"}
  ),
  rule!ruleOne,
  rule!ruleTwo,
  rule!ruleThree
)

Please do not use the eval function - it is undocumented, unsupported, and is not guaranteed to behave in the manner you want or expect.