Ensure a List Item Exists
A 5-step recipe with Microsoft SharePoint. We can help you get access.
Recipe · 5 steps
Ensure a List Item Exists
with Microsoft SharePoint
Idempotently ensure a single list item with a given title exists.
- Confirm the target list exists before reading or writing items, and capture its id for logging and correlation.
- Filter the list for an item whose Title equals the supplied value, returning at most one match. Title is not unique in SharePoint by default, so this treats the first match as authoritative.
- Create the item because no existing item carried the supplied title.
- Fetch the newly created item by id to capture the server-assigned Created, Modified, and AuthorId values, then end the workflow so the already-existed branch does not also run.
- Fetch the pre-existing matched item by id so both branches return the same shape to the caller.
What you'll need to have ready
- listTitle: Title of the list to write into (e.g. "Project Tasks").
- itemTitle: The Title value used both to detect an existing item and to create a new one. This is the de-duplication key for the workflow.
- listItemEntityType: The OData entity type for items in this list, e.g. "SP.Data.ProjectTasksListItem".
For your developer
Arazzo workflow sharepoint:ensure-list-item, 5 operations: getListByTitle → getListItems → createListItem → getListItemById → getListItemById. Specs on APIs.io.