Hide Preview Button Based On File Extension

So I have an interface with a grid that allows the user to preview or download a document. I want to hide the preview button if the file extension of the document is pdf.

Initially I was going to use showWhen but I wondered if a!foreach would also work?

I tried to use the document() function to get the extension, but I realized it only displays it and doesn't retrieve it.

This is what I have for the preview button so far. I haven't configured the download button yet.

a!buttonWidget(
  label: "",
  icon: "eye",
  tooltip: "View",
  value: true(),
  saveInto: {
    local!preview,
    a!save(local!selectedDocument, fv!row)
    
  }
)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    This is rudimentary of course but it should be a matter of setting, say, the "disabled" parameter to "TRUE" when the extension is "PDF" (though, separately, i'm confused why you'd want to hide preview for PDFs, as PDFs are one of the best things that CAN be previewed in Appian's Document Viewer Field...)

    a!buttonWidget(
      label: "",
      icon: "eye",
      tooltip: "View",
      value: true(),
      disabled: document(fv!row, "extension") = "pdf",
      saveInto: {
        local!preview,
        a!save(local!selectedDocument, fv!row)
      }
    )

Reply
  • +1
    Certified Lead Developer

    This is rudimentary of course but it should be a matter of setting, say, the "disabled" parameter to "TRUE" when the extension is "PDF" (though, separately, i'm confused why you'd want to hide preview for PDFs, as PDFs are one of the best things that CAN be previewed in Appian's Document Viewer Field...)

    a!buttonWidget(
      label: "",
      icon: "eye",
      tooltip: "View",
      value: true(),
      disabled: document(fv!row, "extension") = "pdf",
      saveInto: {
        local!preview,
        a!save(local!selectedDocument, fv!row)
      }
    )

Children