String substitute is not working in a!paragraphField( ) function saveInto

Hi,

I am trying to substitute few characters from input string and store/display in the rule input variable (i.e. target).

SAIL: 

a!localVariables(
{
a!buttonArrayLayout(
buttons: a!buttonWidget(
label: "Add",
value: "Add",
saveInto: a!save(ri!target,"2323432345,2343234543,4433443323")
)
),
a!forEach(
items: ri!target,
expression: a!paragraphField(
label: "Target",
labelPosition: "COLLAPSED",
value: substitute(fv!item, ",", char(10)),
saveInto: a!save(fv!item,substitute(fv!item, ",", char(10))),
required: true,
refreshAfter: "UNFOCUS",

)
)
}
)

In the image above I have used substitute( ) function to replace all comma ( , ) character with char(10) but as you can see the display value is converted to desired format where as the data stored in rule input remains the same (comma separated).

Please help me convert the data : 

From : 

2323432345,2343234543,4433443323

To : 

2323432345
2343234543
4433443323

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    I'm a little unclear what you're attempting to accomplish.  You're treating your Rule Input like an array in one spot, but as you can clearly see from your screenshot of its current value, it only has a single value, and there's nothing in the save operation that would cause it to save multiple values.

    Note also that the SaveInto for a field only executes after a user interacts with it - so the value stored in your Rule Input will remain static until you edit the value in the field.  I'd guess that once you try editing the field (like add a character to one of the numbers), it might save the new version with char(10) linebreaks instead of the commas.  But the substitute() function will do nothing up until that point at least.

  • 0
    Certified Lead Developer

    Your code is correct, try saving it on db side once.

    {
      data1: "2323432345" & char(10) & "2343234543" & char(10) & "4433443323",
      data2: substitute(
        "2323432345,2343234543,4433443323",
        ",",
        char(10)
      )
    }

  • 0
    Certified Associate Developer
    and there's nothing in the save operation that would cause it to save multiple values.

    Indeed.

    Why not just save the string with line break in the saveInto of Add button directly? And for later user interaction apply the substitute logic.

    a!localVariables(
      local!target,
      {
        a!buttonArrayLayout(
          buttons: a!buttonWidget(
            label: "Add",
            value: "Add",
            saveInto: a!save({local!target,ri!target},substitute("2323432345,2343234543,4433443323",",",char(10)))
          )
        ),
        a!forEach(
          items: ri!target,
          expression: a!paragraphField(
            label: "Target",
            labelPosition: "COLLAPSED",
            value: fv!item,
            saveInto: a!save({fv!item,local!target},substitute(save!value, ",", char(10))),
            required: true,
            refreshAfter: "UNFOCUS",
    
          )
        )
       }
    )

    I have saved the value in an additional localVariable also just for the demonstration purpose that the value is getting stored in rule input just the way we want since it is not possible to see the raw value of an ri! (however it will show a space by which we can confirm but still). Also your code above do not works for user interaction, fixed that also.