Hi guys,

Certified Associate Developer

I am  trying to do some validations using two fields scheduled date and assignee.

Sheduled date should be mandatory field if the user add any name in assignee field.

If there is no name in assignee field the system should allow to continue without scheduled date.

  Discussion posts and replies are publicly visible

  • Every User Interface input component has a "required" attribute. You can set this using a rule, and you can make the rule examine the value of the assignee field. Your rule can simply check if the assignee's value is null:

  • 0
    Certified Senior Developer
    in reply to Stewart Burchell

    additional info: that this "required" parameter of an UI component is working properly you need to have a buttonwidget with the parameter "submit : true" or at least if the button  parameter "submit" is false or not filled (default value is false) the paramater "validate" needs to be "true". 

  • Adding some sample code illustrating Stewart and Richard's notes, which I agree with:

    a!localVariables(
      local!date,
      local!assignee,
    
      a!formLayout(
        label: "Conditional Required Fields",
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(),
              a!columnLayout(
                contents: {
                  a!sideBySideLayout(
                    items: {
                      a!sideBySideItem(
                        item: a!dateField(
                          label: "Date",
                          value: local!date,
                          saveInto: local!date,
                          required: not(rule!APN_isEmpty(local!assignee))
                        )
                      ),
                      a!sideBySideItem(
                        item: a!pickerFieldUsers(
                          label: "Assignee",
                          value: local!assignee,
                          saveInto: local!assignee
                        )
                      )
                    }
                  )
                }
              ),
              a!columnLayout()
            }
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              validate: true,
              submit: true
            )
          }
        )
      )
    )