Want to disable button conditionally on addRowlink: a!dynamicLink

Hi All,

I want to disable button if data set contains one row already . I want to restrict to add more then one. If it is more than one then Add button should not allow me to add new row.

 

Please help me on that.

addRowlink: a!dynamicLink(
label: "Sample",
value: 'type!{****'(***,***,***),
saveInto: {a!save(***,append(***))}
),

validations: if(
toInteger(
count(
ri!aData
)
) > "1",
FormAPI.setDisabled("???", ??),
""
)

 

Regards

Saurav

  Discussion posts and replies are publicly visible

  • addRowlink: if(length('array') >1, null(), a!dynamicLink(
    label: "Sample",
    value: 'type!{****'(***,***,***),
    saveInto: {a!save(***,append(***))}
    ))

     

     

    Where the 'array' is the object you want to limit...

  • You can't show the link as disabled using addRowLink, but you could hide it if there is already an existing row in the table. You could do something like this:


    load(
    local!rows: {},
    a!gridLayout(
    headerCells: {
    a!gridLayoutHeaderCell(label: "label"),
    a!gridLayoutHeaderCell(label: "")
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
    a!gridLayoutColumnConfig(width: "ICON")
    },
    rows: a!forEach(
    local!rows,
    a!gridRowLayout(
    contents: {
    a!textField(value: fv!item.label, saveInto: fv!item.label),
    a!imageField(
    images: a!documentImage(
    document: a!iconIndicator("REMOVE"),
    link: a!dynamicLink(
    value: fv!index,
    saveInto: a!save(local!rows, remove(local!rows, save!value))
    )
    )
    )
    }
    )
    ),
    addRowLink: if(count(local!rows) > 0, null,
    a!dynamicLink(
    label: "Add New Row",
    value: {label: null},
    saveInto: a!save(local!rows, append(local!rows, save!value))
    )
    )
    )
    )
  • 0
    Certified Lead Developer
    Hi sauravk,

    You can just use if condition for hiding the add row link,

    addRowLink: if(count(ri!data)>1,{},a!dynamicLink(...))