You are viewing limited content. For full access, please sign in.

Question

Question

API - Deleting entry with Audit Reason

asked on October 30 Show version history

Hi,

I want to delete an entry and state the reason for deletion through the API. Because our web app interacts with the Laserfiche repo, I want to log the actual user who deleted the file from our web app as a reason so that it is visible in LF Audit Trail. I tried using the DeleteEntryWithAuditReason class with the Comment property, but in Laserfiche Audit, nothing shows up for the reason for that deleted Entry.

Here is my code:

try
{
    if (parentID > 0)
    {
        string AuthorpersonNumber = "personABC";
        string reason = $"Deleted by {AuthorpersonNumber}";
        DeleteEntryWithAuditReason lfReason = new DeleteEntryWithAuditReason();
        lfReason.Comment = reason;
        AcceptedOperation del = await client.EntriesClient.DeleteEntryInfoAsync(LSRepo, parentID, lfReason);
        await Task.Delay(200);                        
        OperationProgress op = await client.TasksClient.GetOperationStatusAndProgressAsync(LSRepo, del.Token);

        int retryTimes = 0;
        while (!op.Status.Equals(OperationStatus.Completed) && retryTimes < 10)
        {
            await Task.Delay(200);
            op = await client.TasksClient.GetOperationStatusAndProgressAsync(LSRepo, del.Token);

            retryTimes++;
        }

        if (!op.Status.Equals(OperationStatus.Completed))
        {
            throw new AsynchronousOperationException($"Operation Status: {op.Status.ToString()}");
        }
    }
}
catch (Exception e)
{
    throw new AsynchronousOperationException(string.Format("Unable to delete document {0} from Laserfiche: {1}", docID, e.Message));
}

Am I misunderstanding what the Comment field does, or does it have to match a reason in the configured list in the Auditing options in management of the repo?

Ex.

0 0

Answer

SELECTED ANSWER
replied on November 3

Looks like DeleteEntryWithAuditReason.AuditReasonId is not specified in your code. DeleteEntryWithAuditReason needs id of a configured audit reason then LF API will record reason related properties in a separate "Delete Entry" audit event. You are right with "...match a reason in the configured list in the Auditing options in management of the repo".

1 0

Replies

replied on November 3

Hi, Patrick,

 

I see you are looking at event type "Recycle Entry" which is not expected to have reason related properties on Audit Reporting Site. You may filter for "Delete Entry" audit events.

0 0
replied on November 3

In Audit Trail report, it was a filter for Recycle Entry and Delete Entry. I do not see any "Delete Entry" when the API user deletes a file in our environment, and even any user for that matter.

This post seems to clarify that if recycle bin option, there would not be any "Delete Entry" events in Audit Trail.

The event type - Delete,purge and recycle entry in Audit Trail. - Laserfiche Answers

So would this be considered some kind of bug that a "Recycle Entry" would not contain the reason specified through the API and/or LF Repo?

When I manually delete the entry in Laserfiche Repo, I also don't see it in the Audit Trail as the only event that shows in "Recycle Entry"

0 0
SELECTED ANSWER
replied on November 3

Looks like DeleteEntryWithAuditReason.AuditReasonId is not specified in your code. DeleteEntryWithAuditReason needs id of a configured audit reason then LF API will record reason related properties in a separate "Delete Entry" audit event. You are right with "...match a reason in the configured list in the Auditing options in management of the repo".

1 0
replied on November 6

I couldn't find the AuditReasonID in the UI, so instead I did a query on the repo database

SELECT * FROM dbo.audit_reason_choices

After adding this ID in the code, I now see the reason and comment, thank you very much!

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.