Prevent duplicate PDF results in a SharePoint workflow
16 May 2025
A worker can finish writing a result and lose the acknowledgement. Retrying immediately may create a second copy in the wrong state. The supplied six-case local model tracks the selected SharePoint item, its version and the intended destination so the retry can first look for the result it already created.
Which item and version is the worker allowed to process?
Consider a team that stores approved documents in one SharePoint library and wants review copies in another. The proposed direction is source library, processing service, destination library, followed by reconciliation. Specify whether a user requests each operation or an automated trigger detects changes. These are different authority models, even when the resulting PDF looks identical.
Choose between updating the source item and creating a derivative before selecting a connector. Updating preserves one continuing document identity but introduces concurrent-edit and approval questions. Creating a derivative requires an explicit source-to-output relationship and a separately checked access boundary. This guide uses a derivative so that processing does not replace the source.
Where this guidance stops
The example describes a proposed integration using Microsoft Graph's documented concepts. It does not establish an available ArkePDF connector, SharePoint tenant configuration or working authentication. It also does not determine whether a particular PDF operation preserves signatures, accessibility or legal acceptability. Those are separate document acceptance decisions.
Establish permissions and prerequisites
Microsoft Graph permissions and supported APIs
Begin with a resource inventory, then map each action to the documented operation and authentication model. Microsoft explains that Selected permissions require consent, a resource-specific grant and an appropriately scoped token; consent alone does not give resource access. Check the precise operation against that model rather than assuming every selected permission supports every workflow. Microsoft's Selected permissions overview is the starting point, not a completed tenant test.
| Contract input | Required decision or evidence |
|---|---|
| Tenant, site and source drive | Approved environment and library identity |
| Source item and captured version token | Exact document state being processed |
| Destination drive and folder | Allowlisted location, with a responsible owner |
| Application or delegated identity | Reason for the model and documented permissions |
| Classification and processing location | Whether the service may receive these bytes |
| Output policy | New derivative, naming rule and approval route |
Keep tenant and library identifiers alongside item identifiers. A filename such as contract.pdf is useful to a person but is an unsafe routing decision when several libraries contain it. Store credentials outside the document contract; logs should identify the acting application without exposing its token.
Before production, demonstrate a permitted read, a permitted write and a denied operation outside the approved scope. Also establish how the application obtains the bytes, how long it retains them and who can retrieve the result. An administrator's successful test is insufficient evidence for a different runtime identity.
Six simulated library outcomes
Inputs, assumptions and the expected result
The accompanying contract request uses entirely synthetic identifiers. Item SYN-I01 in source drive SYN-D01 has captured token SYN-E5. Operation review-copy-v1 may create a derivative only in drive SYN-D02, folder SYN-F09. These are proposed internal fields, not a Graph request payload.
The intended sequence has five steps. Capture source metadata and the permitted destination. Acquire the corresponding bytes and record their checksum. Process that bounded input. Recheck the source condition and destination before committing. Finally, read the output back and reconcile its identity, source relationship and permissions. If the service cannot bind downloaded bytes to the captured source state, stop and resolve that gap before treating the output as a faithful derivative.
The proposed flow is:
| From | Condition | Next step |
|---|---|---|
| Source item and captured state | Always | Bounded processing job |
| Bounded processing job | Always | Source and destination valid? |
| Source and destination valid? | Yes | Derivative in approved library |
| Source and destination valid? | No | Held for review |
| Derivative in approved library | Always | Read-back and reconciliation |
For write operations that support a precondition, use the documented mechanism. Graph's upload-session documentation says that an if-match token mismatch returns 412 Precondition Failed. It also distinguishes creation under a parent from updating an existing item. That supports a concurrency design; it does not make two separate libraries one atomic transaction. See the upload-session contract.
The local simulation, executed with Python 3.12.14, produced these six expected outcomes:
| Injected situation | Local result |
|---|---|
| Approved request | One model output created |
| Same request delivered again | Existing model output reconciled |
| Source token changes | Request held |
| Different destination library supplied | Request rejected |
| Source marked checked out | Request held |
| Write acknowledgement lost | Existing model output reconciled |
The normal request and its duplicate left one output in the model. The lost-acknowledgement case also left one, avoiding a second creation after an uncertain response. Exact inputs and results are retained in the reconciliation log.
What the results establish
The run demonstrates the proposed guard conditions and bookkeeping in local code. It made no network calls, transformed no PDF and wrote no SharePoint item. It cannot prove remote permissions, checkout behaviour, conditional upload support in a tenant or performance. Those require an authorised integration environment with synthetic documents and captured responses.
Handle retries and version conflicts
Duplicate events, checkout and concurrent changes
Give a processing attempt a stable business key derived from the scoped source identity, source state, operation and destination. A transport retry should recover that attempt. An intentional operation on a newer source state should be identifiable as a different request. Record both the event identifier and business key: multiple events may refer to one business operation.
Before retrying an uncertain write, search the integration's output register and confirm the remote object. An absent acknowledgement is not evidence that creation failed. Conversely, an object with the expected name is not sufficient evidence that it belongs to the job. Verify the stored source reference and checksum or other agreed output evidence.
Treat a changed source, checkout or denied permission as a decision requiring resolution. Repeatedly retrying the same forbidden operation adds noise. The owner should choose to wait, cancel, or authorise a new attempt against a newly captured state. Never silently label an old derivative as representing the latest document.
The verification record should connect source identity, captured state, job, output identity, processing configuration and final read-back. Include failed and held states. A daily report that counts only successful uploads can conceal a queue of older requests that have never reached a business outcome.
Acceptance checklist for a PDF editor and SharePoint
Access inheritance and end-to-end traceability
Test the destination with representative reader identities. Microsoft's permission-listing documentation distinguishes direct and inherited permissions and warns that non-owner callers may receive only permissions applying to them. Therefore, an application's returned list should not automatically be treated as a complete access audit. Review the permission-listing limits.
Use a synthetic document labelled with its source reference, then check:
- An authorised reviewer can open the intended derivative in the intended library.
- A user outside the approved group cannot retrieve it through a copied link or the processing service.
- Duplicate notifications and lost responses produce a reconciled outcome without unapproved extra copies.
- A concurrent edit causes the agreed hold or new-version workflow.
- Failed processing leaves the source intact and exposes an actionable exception.
- Job records can explain every created output and every unresolved source request.
Measure queue age and end-to-end completion time under a representative file mix. Agree limits for file size, concurrency and retries, then observe behaviour when the service is throttled. No universal throughput figure can replace this tenant-specific exercise.
Prepare deployment and support
Rollback and operational responsibility
Assign separate owners for library permissions, application identity, processing quality and queue recovery. Name the person who may release a held document. Document how to disable new intake while allowing already accepted jobs to reach a controlled state.
For this derivative design, rollback begins by stopping new writes and identifying outputs created by the affected configuration. Preserve their provenance. Remove or withdraw them only through the library's approved process; do not delete an entire folder merely because the integration owns some files there. Confirm whether users have already relied on those derivatives.
Take the proposed contract, six local cases and unresolved access questions into a scoped proof of concept. Require actual source-to-result traces, denied-access evidence and a recovery demonstration before approving the connection for business documents.
Prevent duplicate jobs after a network retry
This section answers a narrower question than the rest of this page, and it does not mint a new URL. The original contribution preserved here is a connectivity test matrix and safe offline/online handoff runbook.
A retried request must not become a second job. Give the operation an identity you can recognise after the network returns.
| Step | What you send | What you expect if the response is lost | Result |
|---|---|---|---|
| First attempt | One job, with your own idempotency key | A single stored result | Not run |
| Retry of the same attempt | The same key, not a new document | No second result | Not run |
| A genuinely new document | A new key | A separate result | Not run |
Labelled synthetic case. Use two harmless files and one repeated key. Count stored results. The count is the test. This is not a bypass of the service’s own limits.
The rest of this page remains the parent decision. Use the table for the question in the heading, and leave a cell blank rather than filling it from memory.
Preserve Google Drive file IDs in a PDF workflow
This section answers a narrower question than the rest of this page, and it does not mint a new URL. The original contribution preserved here is a synthetic Drive processing contract with file/version traceability.
A cloud file has an id that is not its name. Write the id before processing and read it after.
| Moment | File id | Version, if the service has one | Name, for humans only |
|---|---|---|---|
| Before | Copied from the service | Copied | Name |
| After | Read again | Read again | May have changed |
Labelled synthetic case. Rename a harmless file after you have stored the id. The id should still find it. If the workflow stored only the name, that is the finding.
The rest of this page remains the parent decision. Use the table for the question in the heading, and leave a cell blank rather than filling it from memory.
Sources
Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with ChatGPT. Editorial and technical checks by Kairos (Codex).
