condition on column in grid

 I need to put a condition on one of the columns in an editable that I'm using.  The code that I'm currently using is not working.  See the code below.  There is a dropdown field in the grid and I have the condition on the 'required' attribute in bold.

 

=a!gridRowLayout(
  contents: {
    a!textField(
      label: "Application Name" & ri!indexRoles,
      value: ri!itemsRoles[ri!indexRoles].applicationName,
      saveInto: ri!itemsRoles[ri!indexRoles].applicationName,
      required: false,
      readOnly: true
    ),
    a!dropdownField(
      label: "Approved",
      labelPosition: "ABOVE",
      placeholderLabel: "--- Select a Value ---",
      choiceLabels: cons!YesNo,
      choiceValues: cons!YesNo,
      value: ri!itemsRoles[ri!indexRoles].approved,
      saveInto: ri!itemsRoles[ri!indexRoles].approved,
      required: if(ri!rejectApplicationsYN = "Return to Customer",true(),false()),
      validations: {}
    ),
    a!imageField(
      label: "delete " & ri!indexRoles,
      images: a!documentImage(
        document: a!iconIndicator("REMOVE"),
        altText: "Remove",
        caption: "Remove " & ri!itemsRoles[ri!indexRoles].applicationName,
        link: a!dynamicLink(
          value: ri!indexRoles,
          saveInto: {
            a!save(ri!itemsRoles, remove(ri!itemsRoles, save!value)),
            /* When modifying the size of the array used in a!applyComponents,  */
            /* make the same change in the "token" array variable               */
            a!save(ri!itemsTokenRoles, remove(ri!itemsTokenRoles, save!value))
          }
        )
      ),
      size: "ICON"
    )

  Discussion posts and replies are publicly visible

  • Hi ,

    Can you try the function : exact( ri!rejectApplicationsYN ,"Return to Customer" ) ?
    Secondly, I would suggest not to use the if function . the resulting output of the function will be itself true or false.
    Lastly, take care of the type for the rule input. It should be of type text.
  • you have written correct code only. For editable grids, it doesn't show up a * mark on the column. But if you try to submit without a value then the form will not be submitted.

     

    Here is the same code I tried and its working for me.

    = a!formLayout(
      label: "Lorem Ipsum",
      instructions: "Lorem Ipsum",
      firstColumnContents: {
        a!gridLayout(
          headerCells: {
            a!gridLayoutHeaderCell(
              "Col1"
            ),
            a!gridLayoutHeaderCell(
              "Col2"
            ),
            a!gridLayoutHeaderCell(
              "Col2"
            )
          },
          rows: a!gridRowLayout(
            contents: {
              a!textField(
                label: "Application Name" & ri!indexRoles,
                value: ri!itemsRoles[ri!indexRoles].applicationName,
                saveInto: ri!itemsRoles[ri!indexRoles].applicationName,
                required: false,
                readOnly: true
              ),
              a!dropdownField(
                label: "Approved",
                labelPosition: "ABOVE",
                placeholderLabel: "--- Select a Value ---",
                choiceLabels: {
                  "Yes",
                  "No"
                },
                choiceValues: {
                  "Yes",
                  "No"
                },
                value: ri!itemsRoles[ri!indexRoles].approved,
                saveInto: ri!itemsRoles[ri!indexRoles].approved,
                required: if(
                  ri!rejectApplicationsYN = "Return to Customer",
                  true(),
                  false()
                ),
                validations: {}
              ),
              a!imageField(
                label: "delete " & ri!indexRoles,
                images: a!documentImage(
                  document: a!iconIndicator(
                    "REMOVE"
                  ),
                  altText: "Remove",
                  caption: "Remove " & ri!itemsRoles[ri!indexRoles].applicationName,
                  link: a!dynamicLink(
                    value: ri!indexRoles,
                    saveInto: {
                      a!save(
                        ri!itemsRoles,
                        remove(
                          ri!itemsRoles,
                          save!value
                        )
                      ),
                      /* When modifying the size of the array used in a!applyComponents,  */
                      /* make the same change in the "token" array variable               */
                      a!save(
                        ri!itemsTokenRoles,
                        remove(
                          ri!itemsTokenRoles,
                          save!value
                        )
                      )
                    }
                  )
                ),
                size: "ICON"
              )
            }
          )
        )
      },
      secondColumnContents: {
        /* Add components here for a two-column form */
        
      },
      buttons: a!buttonLayout(
        primaryButtons: {
          a!buttonWidgetSubmit(
            label: "Submit",
            style: "PRIMARY",
            saveInto: {}
          )
        },
        secondaryButtons: {
          a!buttonWidgetSubmit(
            label: "Cancel",
            style: "NORMAL",
            value: true,
            saveInto: ri!cancel,
            skipValidation: true
          )
        }
      ),
      validations: {}
    )

     

    output:

  • Hi Kondetiv. The code is not working for me. The cell does not turn red as you have it displayed. You mentioned in a previous response to "make sure ri!rejectApplicationsYN variable should not be null. Because we cannot compare a null value with any other value. Try to put the null checks and verify the code once again." What do you mean by this. How to I put the null checks?
  • Hi Alok. Can you provide more details on this? How do I use the extract function and what should I used instead of the if function? The rule interface input is of text type.
  • Hi sswilliams ,

    May i know the type of button you used, I mean a "Submit" or "Normal" button, If you are using "a!buttonWidget" then you should passed the Validate flag, eg

    a!buttonWidget(
       validate:true(),
       label: "Submit",
       style: "PRIMARY",
       saveInto: {}
    )

  • check for the following things
    1- check the type of ri!rejectApplicationsYN, it should be text
    2- use a submit button like a!buttonWidgetSubmit() to show error


    *remove the if statement as it is redundant here

    let me know if this doesn't work out 

  • Hi sswilliams,
    This is how exact functions looks like
    exact(text1, text2)
    Compares two given Texts in a case-sensitive manner, returning true only if they are exactly the same
    Returns: Boolean