Required fields, if other field is empty

So I am very new at Appian and I have a question about required fields.

I have an interface with two sections:

In one section is just a field where one can enter an ID number.

The other section consists of several fields that are required, if the ID number of the first section is unkown.

So basically, I enter the ID number, the fields shoudl not be required, but as long as the ID field is empty all the other fields should be required.

 

Can anyone help?

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    With the help of local variable you can achieve this.
    Here is the sample code..

    load(
    local!isRequired,
    a!textField(
    label: "ID",
    saveInto: {
    a!save(
    local!isRequired,
    true /*With Required Condition*/
    )
    }
    ),
    a!textField(
    label: "Other Field(s)",
    required: if(
    local!isRequired=true(),
    true,
    false
    )
    )
    )
  • Have made some modifications in the code provided by Yoga.

    load(
    local!isRequired,
    local!val1,
    local!val2,
    a!formLayout(
    contents: {
    a!sectionLayout(
    contents: {
    a!textField(
    label: "Test1",
    value:local!val1,
    saveInto: {local!val1,
    if(isnull(local!val1),
    a!save(local!isRequired,null),
    a!save(local!isRequired,true())
    )

    },
    refreshAfter: "UNFOCUS"
    )
    }
    ),
    a!sectionLayout(
    contents: {
    a!textField(
    label: "Test2",
    value: local!val2,
    saveInto: local!val2,
    required: if(local!isRequired,false,true),
    refreshAfter: "UNFOCUS"

    )
    }
    )
    }
    )
    )

    This will help you. Try it out!!

    Thanks,
    Aditya.
  • load(
      local!id,
      {
        a!sectionLayout(
          label: "Section1",
          contents: {
            a!textField(
              label: "Text",
              labelPosition: "ABOVE",
              value: local!id,
              saveInto: local!id,
              refreshAfter: "UNFOCUS",
              validations: {}
            )
          }
        ),
        a!sectionLayout(
          label: "Section2",
          contents: {
            a!textField(
              label: "Text1",
              labelPosition: "ABOVE",
              saveInto: {},
              refreshAfter: "UNFOCUS",
              required: isnull(
                local!id
              ),
              validations: {}
            )
          }
        ),
        a!textField(
          label: "Text2",
          labelPosition: "ABOVE",
          saveInto: {},
          required: isnull(
            local!id
          ),
          refreshAfter: "UNFOCUS",
          validations: {}
        )
      }
    )
    Hi christianr0002,

    Save value of ID in some local variable and compare that variable in "required" property of second section fields by using isnull() function if  local variable is null then return true fro "required" property otherwise false...

    in this way you can handle the situation....

    Refer the following code...

     

    load(
      local!id,
      {
        a!sectionLayout(
          label: "Section",
          contents: {
            a!textField(
              label: "Text",
              labelPosition: "ABOVE",
              value: local!id,
              saveInto: local!id,
              refreshAfter: "UNFOCUS",
              validations: {}
            )
          }
        ),
        a!sectionLayout(
          label: "Section",
          contents: {
            a!textField(
              label: "Text1",
              labelPosition: "ABOVE",
              saveInto: {},
              refreshAfter: "UNFOCUS",
              required: isnull(
                local!id
              ),
              validations: {}
            )
          }
        ),
        a!textField(
          label: "Text2",
          labelPosition: "ABOVE",
          saveInto: {},
          required: isnull(
            local!id
          ),
          refreshAfter: "UNFOCUS",
          validations: {}
        )
      }
    )

    see the out put of above code as...

    when id is null

    when id is not null

    Thanks and Regards,

    Amit Behere

  • thank you so much all of you. I really appreciate the help