Skip to main content
Known Participant
October 24, 2024
Question

Multiple 'saveinto' not working with condition in button widget

  • October 24, 2024
  • 5 replies
  • 8 views

                  a!columnLayout(
                    contents: {
                      a!buttonArrayLayout(
                        buttons: {
                          a!buttonWidget(
                            label: "Next",
                            size: "LARGE",
                            style: "SOLID",
                            saveInto: {
                              if(
                                len(ri!checklists) > 1,
                                {
                                  a!save(ri!steps, append(ri!steps, "name")),
                                  a!save(ri!nextStep, 3)
                                },
                                {
                                  a!save(
                                    local!showAddChecklistErrorMessage,
                                    true()
                                  )
                                }
                              )
                            }
                          )
                        },
                        align: "END",
                        marginBelow: "NONE"
                      )
                    }
                  )

Here is the code, I have button with save something based on a condition, now within this 2 save statement 

a!save(
ri!steps,
append(ri!steps, "name")
),
a!save(ri!nextStep, 3)
only first one is working next is not working. Let me know what I am doing wrong

5 replies

somasundaram.d
Employee
October 24, 2024

What was the issue

Known Participant
October 25, 2024

a!save(ri!nextStep, 3) not changing the value

vishalg0003
New Participant
October 25, 2024

Its because the 2nd a!save has wrapped inside {}. 

a!columnLayout(
contents: {
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Next",
size: "LARGE",
style: "SOLID",
saveInto: {
if(
len(ri!checklists) > 1,
{
a!save(ri!steps, append(ri!steps, "name")),
a!save(ri!nextStep, 3)
},
a!save(
local!showAddChecklistErrorMessage,
true()
)
)
}
)
},
align: "END",
marginBelow: "NONE"
)
}
)


Known Participant
October 25, 2024

The problem with the `len` function and the login must be >=,. The correct function for the length of the array in `length`, and after changing the logic to >= now it is working as expected.