Building a (process) variable in Appian using the value of another one?

610 views Asked by At

As far as I understand, it is not possible in Appian to dynamically construct (process) variable names, just like you would do e.g. with using backticks like MY_OBJECT=pv!MY_CONS_`extract(valueOfPulldown)`. Is that correct? Is there a workaround?

I have set of Appian constants, let's call them MY_CONS_FOO, MY_CONS_BAR, MY_CONS_LALA, all of which are e.g. refering to an Appian data store entity. I would like to write an Appian expression rule which populates another variable MY_OBJECT of the same type (here: data store entity), depending e.g. of the options of a pull-down menu having the possible options stored in an array MY_CONS_OPTIONS looking as follows

FOO
BAR
LALA

I could of course build a lengthy case-structure which I have to maintain in addition to MY_CONS_OPTIONS, so I am searching for a more dynanmic approach using the extract() function depending on valueOfPulldown as the chosen value of the pulldown-menu.

Edit: Here the expression-rule (in pseudo-code) I want to avoid:

if (valueOfPulldown = 'FOO') then MY_OBJECT=pv!MY_CONS_FOO
if (valueOfPulldown = 'BAR') then MY_OBJECT=pv!MY_CONS_BAR
if (valueOfPulldown = 'LALA') then MY_OBJECT=pv!MY_CONS_LALA

The goal is to be able to change the data store entity via pulldown-menu.

1

There are 1 answers

1
Jakub On

This can help you find what is behind your constant.
fn!typeName(fn!typeOf(cons!YOUR_CONSTANT)).

Having in mind additional details I would do as follows:

  1. Create separate expression that will combine details into list of Dictionary like below:

Expression results (er):

   {
      {dd_label: "label1", dd_value: 1, cons: "cons!YOUR_CONSTANT1" }
      ,{dd_label: "label2", dd_value: 2, cons: "cons!YOUR_CONSTANT2" }
    }
  1. on UI for your dropdown control use er.dd_label as choiceLabels and er.dd_value as choiceValues

  2. when user selects value on Dropdown save dropdown value to some local variable and then use it to find your const by doing:

property( index(er, wherecontains(local!dropdownselectedvalue, tointeger(er.dd_value))), "cons")

  1. returned value of step 3 is your constant

This might not be perfect as you still have to maintain your dictionary but you can avoid long if...else statements.

As a alternative have a look on Decisions Tables in Appian https://docs.appian.com/suite/help/21.1/Appian_Decisions.html