Variable is not refreshing

Good afternoon all.

Here is what's going on.

I am given a string, or Text variable. This variable is used to store employee IDs. Although it is one variable, it can contain several IDs (or contain none). There is nothing I can do about this and I cannot change this. Now, I need to check if this value has any of the following: no values, one value, or many values. This Text can dynamically change when a user selects IDs, or removes them, from a custom picker. If the Text has several values, I am currently using split() to separate the IDs into an array, which is working fine. Then, I have a local variable that uses the array to get the names for each of those IDs. Unfortunately, the last ID is contained in the new array, but fails to update to the name. For example, if the following IDs exist: 1, 2, and 3, It will show: Peter, Paul, and 3. I'm currently using Appian 21.3.

local!employeeIDs: if(
    isnull(ri!record.employeeIDs),
    null,
    split(ri!record.employeeIDs, ";")
  ),	
local!employeeNames: a!refreshVariable(
    value: if(
      or(
        rule!isEmpty(local!employeeIDs),
        length(local!employeeIDs) = 0
      ),
      null,
      a!forEach(
        items: local!employeeIDs,
        expression: rule!GetNameByID(fv!item)
      )
    ),
    refreshOnVarChange: local!employeeIDs
  )

If I did a terrible job explaining my issue, please let me know. I will gladly elaborate on the issue. Any and all advice will be greatly, greatly appreciated. Thanks.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I don't see anything particularly wrong with the posted code snippet (beyond certain code style nitpicks).  One important thing to note is that your "refreshOnVarChange" is unnecessary as it's redundant; all a!localVariables() variables automatically have "refreshOnReferencedVarChange" set to TRUE by default unless overridden, so your local!employees variable would already refresh on any update to local!employeeIDs.  The same would be true for local!employeeIDs upon update to ri!record.employeeIDs.

    Just to double check, what data type is ri!record.employeeIDs?  Are we assuming it's a single string of semicolon-separated ID values with no additional spaces in between?  I'm just checking because a common point of confusion around here arises from accidentally assuming Appian's default method of displaying an array of data in text (separated by semicolons) is equivalent to a semicolon-separated text list, even though these two things aren't direclty equivalent without some type-casting.

    • ri!record.employeeIDs is type Text.
    • There is a space after each semicolon. 
Reply Children
No Data