Skip to main content
December 7, 2021
Question

If condition with another condition inside the result part.

  • December 7, 2021
  • 8 replies
  • 0 views

Hello, 

I am thinking how I can achieve something like this with seal only, 

a!localVariables(
local!data:
if(
isnull(local!a1),

updatedictionary(),
/* Second Condition */
if(isnull(local!b1),
),

),
null
),
local!data
)

basically if condition for null value, if it is null exit, if it is not null do action and that check next value, problem is that in the if there are condition, true(), false()) where it does not allows a action with another if inside the result part. 

Any idea which is the best approach ?

    8 replies

    December 7, 2021

    One comment on the condition, the right functionality is inside the graphic in the code it is reversed, ignore that. if is null than result is null. 

    csteward
    December 7, 2021

    Hi Vladimir, you should be able to achieve this but the solution will depend on where you are performing this and what it is doing.  Is this used for a!save() when a button is depressed or a field is changed, or what are we doing here exactly, etc?

    Some quick examples with saving data on button press, Submit 1 cascades the if() statements and Submit 2 separates them out independantly.

    a!localVariables(
      local!data1: null,
      local!data2: "test",
      local!value1,
      local!value2,
      
      a!buttonLayout(
        primaryButtons: {
          a!buttonWidget(
            label: "Submit 1",
            submit: true,
            saveInto: {
              if(
                isnull(local!data1),
                {}, /* do nothing */
                if(
                  isnull(local!data2),
                  {}, /* do nothing */
                  a!save(local!value2,"test")
                )
              )
            }
          ),
          a!buttonWidget(
            label: "Submit 2",
            submit: true,
            saveInto: {
              if(
                isnull(local!data1),
                {}, /* do nothing */
                a!save(local!value1,"test")
              ),
              if(
                isnull(local!data2),
                {}, /* do nothing */
                a!save(local!value2,"test")
              )
            }
          )
        }
      )
    )

    December 7, 2021

    well it is actually not related to button press, it is one expression which is given certain data and have to check it all. lines of data, if the next line does not contains data stop iterations are this point.