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
Discussion posts and replies are publicly visible
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.
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" ) } ) } )