how to use the a constant to create a document link?

Hello,

I am trying to add a document link to an interface. I found the a!documentDownloadLink function and it tells me to create a constant to point to my documents but I am a bit lost.

This is an interface where a supervisor will approve or deny a request so the document link in the form should be attached to the specific request. What do I need to do in the cosntant to point specifically to that value?

The value is store in my recordType as an integer and it is added to the record through an attachment component in a record action. 

any help is appreciated

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Senior Developer

    I don't see that constant is required for a!documentDownloadLink()

    If document id stored in DB and document id exist in appian simply use document id from record. use below code to understand more.

    {
      a!linkField(
        label: "Download document",
        labelPosition: "ABOVE",
        links: {
          a!documentDownloadLink(
            label: document(
              documentId:{}, /*Add your document id here from record.*/ 
              property: "name"
            ),
            document: {} /*Add your document id here record.*/
          )
        }
      )
    }
  • One nitpick / advice here - I never recommend anyone use a!linkField() at all for any reason, now that we have a!richTextDisplayField().  The latter makes it more easy and flexible to control the link, what it displays, and when to display it.

    {
      a!richTextDisplayField(
        label: "Download document",
        value: {
          a!richTextItem(
            text: {
              "Click Here to Download ", /* whatever label you want */
              a!richTextIcon(icon: "file-export")
            },
            link: a!documentDownloadLink(
              /*label: "" */  /* "label" component is not used in this context - the rich text item's text is sufficient */
              document: 123, /* Your document id here */
              showWhen: true() /* add conditionality here to turn the link "on" or "off" as needed */
            )
          )
        }
      )
    }

    Plus, we get rich text formatting options including icons, links that can be on individual words in the middle of a longer string, etc.

Reply Children
No Data