Generate download link when clicking on button

Certified Senior Developer

Hi there,

I have created a button to generate CSV file but after clicking on button- page redirects to home page. 
I want to create document link when clicking on button so that file get downloaded. How can I do this in interface?

Thanks

  Discussion posts and replies are publicly visible

Parents Reply
  • This is all you need.  The "label" parameter in document download link is irrelevant when used in a rich text item, which just uses the value you place in the "text" parameter.  I've removed everything irrelevant here and fixed the aforementioned "double-negative" error.

    a!richTextDisplayField(
      value: a!richTextItem(
        text: "Dowload Document",
        showWhen: a!isNotNullOrEmpty(local!docId),
        link: a!documentDownloadLink(
          document: local!docId
        )
      )
    )

    If you want to go slightly fancier you can make use of the super flexible nature of being able to stack multiple a!richTextItem() elements inside one Rich Text Field, and add one that shows up specifically as a placeholder while the Doc ID is still blank:

    a!richTextDisplayField(
      value: {
        a!richTextItem(
          text: "Dowload Document",
          showWhen: a!isNotNullOrEmpty(local!docId),
          link: a!documentDownloadLink(
            document: local!docId
          )
        ),
        
        /* show a special placeholder while local!docId is still blank: */
        a!richTextItem(
          showWhen: a!isNullOrEmpty(local!docId),
          text: "(No Document)"
        )
      }
    )

Children