Skip to main content
September 1, 2023
Solved

How to convert 3;4;5 into {3,4,5}

  • September 1, 2023
  • 7 replies
  • 0 views

I am saving multiple dropdown values like 3;4;5 and if I am passing the same value into an expression rule and doing for each it isn't taking individual value instead consider as 345.

How to convert 3;4;5 into {3,4,5}

    Best answer by stefanhelzle0001

    I am not sure what you are doing here.

    But in general, storing a list of integers into a single string turns {1, 2, 3} into "1;2;3". This is what you observe. To avoid this, make sure to keep your data types a list of integer consistently.

    And no, working around that issue by using split(), works, but is a super ugly solution and will get you into trouble on the long run!

    7 replies

    stefanhelzle0001
    Brainy
    September 1, 2023

    The dropdown returns a list of values. What data type is the rule input of the expression? It should be a list of integer.

    hemap0003Author
    September 1, 2023

    I am passing this value into local variable and then from a!forEach(items :local!data,expression: rule!getData(employeeid: fv!item).

    local!data : ri!employeeData[Recordtype!OD_EMP_RECORDS.fields.employeeid].

    stefanhelzle0001
    Brainy
    September 1, 2023

    I am not sure what you are doing here.

    But in general, storing a list of integers into a single string turns {1, 2, 3} into "1;2;3". This is what you observe. To avoid this, make sure to keep your data types a list of integer consistently.

    And no, working around that issue by using split(), works, but is a super ugly solution and will get you into trouble on the long run!

    September 1, 2023

    HI [mention:ef0696ae0dea4877a9e109587f8c50ae:e9ed411860ed4f2ba0265705b8793d05]

    Please find the code below. By passing the selected dropdown value into an expression rule and iterating through it using a foreach loop, it will become the 'items' for further processing.

    a!localVariables(
    /*The below localVariable will hold selected drop down values*/
      local!dropDownValues: tostring({ 3, 4, 5 }),
      if(
        a!isNullOrEmpty(local!dropDownValues),
        "",
        split(local!dropDownValues, "; ") /*By using split function the data will be displayed as a list*/
      )
    )

    stefanhelzle0001
    Brainy
    September 1, 2023

    That is not solving the issue, but trying to work around it, after creating it in the first place.