Skip to main content
davinar9817
February 15, 2023
Solved

Hide Preview Button Based On File Extension

  • February 15, 2023
  • 2 replies
  • 0 views

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)
    
  }
)

Best answer by mikes0011

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)
  }
)

2 replies

mikes0011
mikes0011Answer
Brainy
February 15, 2023

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)
  }
)

The Expression Guru
davinar9817
February 15, 2023

Hiding the preview is just a little exercise! It's not actually going to be implemented.

Although I did get this error

Edit: Fixed it and it seems to work now