Skip to main content
anveshs420634
August 4, 2025
Question

Need to update audit in table while clicking a!safelink

  • August 4, 2025
  • 13 replies
  • 0 views

We are using a!safelink to provide provision to download a file using presigned URL. The requirement is we need to store which user clicked on the link and when in audit table, but

as in the safelink there are no saveinto parameter . I tried multiple other ways but all in vain.

I am unable to find a solution, where on a single click user able to navigate using presigned url as well as in backed it writes to audit.

 please advise what to do that in this case and any work around we can do to achieve the requirement.

Thank you in advance

13 replies

harshas2775
August 4, 2025

It is not possible to download and write to audit in single click. You can however have a process with start form. User can click on the download link in the start form and close the form using submit button. In process you can use pp!initiator to write the data in audit. 

shubhama926776
August 4, 2025

Since a!safeLink doesn't support saveInto, we implement a two-step download process - first click logs the audit, second click downloads the file.

Have a look at sample code for your reference:

a!localVariables(
  /* Track whether the initial link has been clicked */
  local!linkClicked: false,
  local!presignedUrl: "www.google.com",
  {
    a!linkField(
      links: {
        /* STEP 1: Initial link that triggers audit logging */
        a!dynamicLink(
          label: "Click to Download",
          value: true,
          saveInto: {
            /* Set flag to show the actual download link */
            local!linkClicked,
            /* Write audit record using a!writeRecords */
            /*a!writeRecords(records: {}, onSuccess: {}, onError: {})*/
          },
          showWhen: not(local!linkClicked)
        ),
        /* STEP 2: Actual download link shown after audit is logged */
        a!safeLink(
          label: "Download Now",
          uri: local!presignedUrl,
          /* Only show after the first link is clicked and audit is logged */
          showWhen: local!linkClicked,
          openLinkIn: "NEW_TAB"
        )
      }
    )
  }
)

anveshs420634
August 11, 2025

Thanks [mention:65b14048184a4eb5aff3a76c87b97431:e9ed411860ed4f2ba0265705b8793d05] [mention:9861aef97eb2483a8b76175d9eda1e37:e9ed411860ed4f2ba0265705b8793d05]  for your response. But since solution I wanted is with single click and I have already implemented this with two clicks. Will look forward for Appian to introduce this feature since this is a valid Use case.

mikes0011
Brainy
August 11, 2025
Will look forward for Appian to introduce this feature

Honestly I'm not sure how technologically feasible it is - just due to the nature of how standard web-links work.  As far as I can tell they might be stuck completely separating (functionally) links that actually open a web link, from other styles of link that intiate any sort of interface-side and/or appian-side data processing, etc.

mikes0011
Brainy
August 11, 2025

This is how SafeLink works, and has always worked.

The best supported solution will simply involve 2 user clicks, in a large variety of possibilities. One click will persist whatever data you want to the DB, and the other click will be the user opening their link.  I would suggest that you require the user to first click a button (for instance) to "generate link" or "show link" where it both un-hides the existing link but then also persists your log data (and anything else you like).

harshas2775
August 11, 2025

An issue with this design is that user details will be added to log even before they downloaded! If user generates the link but doesn’t download then log has an invalid/inaccurate entry. Writing to logs after download is more integral though might need additional click as suggested in my earlier response! 

mikes0011
Brainy
August 11, 2025

Except your solution (while also good) has a similar, if reversed, weakness - namely, you can't force a user to click "submit" on a process start form, so some users will merely click away / close the browser window / etc, meaning they'd never get a log entry generated.

In my solution above, the caveat that the customers would need to understand and accept would be "these logged instances are where a user was SHOWN the external link / download link".  While some exceptions might exist where the user "generated" the link but never clicked it, there would at least be zero link clicks without a log entry.  (Also even in your Start Form solution, some users could still click into the start form and hit "submit" without clicking on the external / download link, leaving us with the same logging disparity anyway.)

santhoshr801229
November 25, 2025

Hi Anvesh, Not sure if you are still looking for a solution. I had a similar requirement, and this is how I got it done. 

Step 1: Create a Web API (POST Method) that creates audit history either using startProcess or writeRecords logic. 

Step 2: Create an integration to make a call to this Web API. We need these 2 objects since we cannot call POST Web API as part of a safe link.

Step 3: Create a Web API (GET Method) which will redirect the user to the appropriate link as show in the inserted code.

Step 4: Provide the URL of the Web API created at Step 3 as safe link.

Hope this helps.

a!httpResponse(
  statusCode: 301,
  headers: {
    a!httpHeader(
      name: "Location",
      value: http!request.queryParameters.uri  
      /*This is the URL to which the user should be navigated*/
    )
  },
  body: rule!PREFIX_POST_AuditHistory(
    .......
  )
  /*this is the integration call to write audit history*/
)