On Single Click Download The Document and Write record in DB

Hi Everyone,

Is there any way to Download the document and Write operation into Data Base on One Link[One Click Event] from User Interface level.

We are working on 18.2.

Thanks In Advance!!

  Discussion posts and replies are publicly visible

  • Hi Venkatesh,

    use this function getdatasubsetdownloadlinkfromprocess() or getdatasubsetdownloadlinkfromrule() in the interface which will genearate the link.
    Configure the interface in Process model to write into db.


    Hope it will helps.


    Thanks,
    Sudha.P
  • Thanks For The Response Sudha.

    The getdatasubsetdownloadlinkfromprocess() or getdatasubsetdownloadlinkfromrule() both this links will return URL and In Your Process Model should return Exportable DataSubset.

    AFAIK This will only for Excel file download for customized data[From Data Base OR Other] .

    In My Use Case I have Document , I will provide Document download link. In this case user will able to download But I need to capture that operation also on click of that link .Here no need to generate new document, Already we have existing one.

    Thanks!!

  • Hi Venkatesh,

    AFAIK, This functionality is not available in Appian right now. Instead you can achieve this in the following.

    1) You can see the current user is in the list of download history of this document.  This is in turn has lot of limitations (like if the same user is already downloaded the document for the first time and when he visited the same form in the next time and not downloaded the document next time you can still see the user in the list because he has already downloaded it) so this may not meet your requirement if it is template kind of document.

    2) You can have dynamic link on the page first and when user has clicked on that link we will just show them that actual document and then on click of dynamic link you can make an entry in database. In this case we must assume that when user clicks on Dynamic link then he is intended to download the document. 

    This is what I feel we can do that. Let's see what other folks responses.

  • Hi Venkatesh,
    2nd approach mentioned by "Shanmukha" should work for you. Small code base for that is,
    a!dynamicLink(
    label: "Download",
    value: ,
    saveInto: {
    a!writeToDataStoreEntity(

    )
    }
    )
  • 0
    Certified Lead Developer
    I would prefer to store the button action on interface level, and in process model you can save the data as well as create a link for export file . and rel-loop back to the same user input task again. something similar we have done in below screenshot. Also with this approach process model give you the more flexibility .
  • Thanks For The Response  

    You are saying first will display dynamic link with some label, Once Users clicks on that link will write into Data Base and At the same time display the Document download link now.

    In this case we need to assume for the first time click event user downloaded the document, Instead of actually download the document. If we don't have any other option will work on it.

    Let's see what other folks responses.

  • : Thanks for the response, How will generate the Link in PM? . I didn't find any screenshot.
    Thanks!!
  • 0
    Certified Lead Developer
    in reply to Venkatesh Suram

    Below is the screenshot. So in below scenario When user clicks on 'Generate Export File' Button , we save the button action  in process variable and submit the form. once submitted base on the button action we have some database write logic and some document generation code . once the document is generated reloop to the same form and show the link to generated document using a!linkField

  • Thanks For The response  

    In My scenario no need to generate a new document , I have already document . When user clicks on the link he should able to  download and write the operation into data base.

    In my use case instead of looping the same form we can work with link field, Please find below sample code.

    load(
      local!isShowDocument:false(),
    {
      a!linkField(
        label: "",
        labelPosition: "ABOVE",
        links: {
          a!dynamicLink(
            label:"Show Document",
            value:true(),
            saveInto: {
             local!isShowDocument,
            /*We can perform the Write Operation here*/
           /* a!writeToDataStoreEntity(
              
            )*/
            },
            showWhen:not(local!isShowDocument)
          ),
          a!documentDownloadLink(
            label:"Download Document",
            document:todocument(12345),
            showWhen:local!isShowDocument
          )
        }
      )
    }
    )

    Same thing suggested by Shanmukha (raghavendrar0001), But here we need to assume once user clicks on the show Document label downloaded the document irrespective of the download action.