MS SharePoint – Lists – Update List Item
MS SharePoint – Lists – Update List Item
Updates field values on one list record. Input Fields is a required JSON object sent directly to the fields endpoint, without an outer fields wrapper. Microsoft returns a fieldValueSet; CloudTools places it into SharePointListItem.fields and sets id from the input. The result is not a fully refreshed list item and its other metadata and additionalProperties are not populated by this method. No If-Match input is exposed.
Action details
| Property | Value |
|---|---|
| Action label | MS SharePoint – Lists – Update List Item |
| Category | CloudTools |
| Apex class and method | UpdateSharePointListItem.updateListItem |
| Input type | UpdateSharePointListItem.UpdateSharePointListItemInput |
| Output type | List<SharePointListItem> |
| Authorization | OAuth Delegated (Authorization Code) or OAuth Application (Client Credentials), subject to endpoint restrictions. |
| Microsoft Graph request | PATCH /v1.0/sites/{siteId}/lists/{listId}/items/{itemId}/fields |
Prerequisites and permissions
Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete user sign-in for delegated access. For supported application access, grant application permissions and administrator consent. The calling identity must have access to the relevant site, list, library, or item; tenant policy and resource configuration still apply.
The action permission provider declares the following permission alternatives. These are not cumulative requirements and not all are least privileged. Check the linked Microsoft reference for the endpoint, authorization type, and current restrictions.
| Permission type | Declared alternatives |
|---|---|
| Delegated | Sites.ReadWrite.All |
| Application | Sites.ReadWrite.All |
See the Microsoft operation and permissions reference.
Inputs
Supply one non-null request with nonblank required identifiers. IDs must belong to the indicated site, list, or drive; do not substitute Salesforce IDs or browser URLs.
| Input | Apex field | Type | Required | Description |
|---|---|---|---|---|
| Site Id | siteId | String | Yes | SharePoint site identifier. |
| List Id | listId | String | Yes | SharePoint list identifier. |
| Item Id | itemId | String | Yes | SharePoint list item identifier. |
| Input Fields | inputFields | String | Yes | JSON object of field values to update (for example {“Color”:”Fuchsia”,”Quantity”:934}). Use a JSON object, not an array or an escaped JSON string. The Title example below assumes that column is writable and all other required fields are satisfied. |
The global invocable input does not expose connectorId. Direct subscriber Apex and Flow calls use CloudTools connector selection. Resolve dynamic values before invocation; this action does not resolve replacement tokens.
Outputs
Returns one SharePointListItem inside a list, or an empty list if no response is mapped. Check for an empty result before reading fields.
| Output | Apex field | Type | Description |
|---|---|---|---|
| Id | id | String | Unique identifier for the list item. |
| Name | name | String | Name of the list item. |
| Description | description | String | Description of the list item. |
| Created Date Time | createdDateTime | String | Created date and time for the list item. |
| Last Modified Date Time | lastModifiedDateTime | String | Last modified date and time for the list item. |
| Web URL | webUrl | String | Web URL of the list item. |
| ETag | eTag | String | Entity tag for optimistic concurrency. |
| OData Type | odataType | String | OData type for the list item. |
| OData ETag | odataEtag | String | OData ETag for the list item. |
| Created By | createdBy | SharePointIdentitySet | Identity set representing who created the item. |
| Last Modified By | lastModifiedBy | SharePointIdentitySet | Identity set representing who last modified the item. |
| Parent Reference | parentReference | SharePointParentReference | Parent reference for the item. |
| Content Type | contentType | SharePointCTInfo | Content type for the list item. |
| Fields | fields | SharePointFieldValueSet | List item field values. |
| Drive Item | driveItem | MSGraphDriveItem | Related drive item if one exists. |
| Versions | versions | List<SharePointVersion> | Versions for this list item. |
| Document Set Versions | documentSetVersions | List<SharePointDocumentSetVersion> | Document set versions for this list item. |
| SharePoint IDs | sharepointIds | SharePointIds | SharePoint identifier set for the list item. |
| Additional Properties | additionalProperties | List<DynamicObject> | Additional properties from user-defined query. |
Field values are available through fields.additionalData as DynamicObject name/value entries. Normal response mapping also retains flattened and extra properties in additionalProperties. Update List Item is an exception: it constructs only id and fields from the fieldValueSet response. Related driveItem, versions, and documentSetVersions are populated only when Microsoft returns them.
Use in Flow
Add MS SharePoint – Lists – Update List Item in Flow Builder. Use a Microsoft 365 application connector configured as Set as default for Flow automations, supply the required resource IDs, and add fault handling. Delegated connections are not supported for CloudTools Flow automation. This implementation processes only the first input request and is not a bulk operation.
Use in custom Apex
This subscriber-org example uses the Apptigent namespace. Replace the identifiers, configure the connector, and run in a context that permits callouts. Arrange authorization before calling and handle exceptions in the caller.
Apptigent.UpdateSharePointListItem.UpdateSharePointListItemInput request =
new Apptigent.UpdateSharePointListItem.UpdateSharePointListItemInput();
request.siteId = 'REPLACE_WITH_SITE_ID';
request.listId = 'REPLACE_WITH_LIST_ID';
request.itemId = '12';
request.inputFields = '{"Title":"Project update"}';
List<Apptigent.SharePointListItem> results =
Apptigent.UpdateSharePointListItem.updateListItem(
new List<Apptigent.UpdateSharePointListItem.UpdateSharePointListItemInput>{ request }
);
Apptigent.SharePointListItem item = results.isEmpty() ? null : results[0];
System.debug(item == null ? null : item.id);
Use in a Lightning Web Component
Use updateSharePointListItem from msSharePointConnectorLib, through MSSharePointConnectorController. These c/ imports apply to an LWC in the same namespace. The function accepts one request object, including connectorId when applicable.
Set request.connectorId to select a configured Connector record. The controller passes this request selection through SharePointAction. The field belongs to the controller request, not the global invocable input type.
sharePointActionExample.js
import { LightningElement } from 'lwc';
import { updateSharePointListItem, MSSharePointObjects } from 'c/msSharePointConnectorLib';
export default class SharePointActionExample extends LightningElement {
connectorId = 'REPLACE_WITH_CONNECTOR_RECORD_ID';
result = null;
errorMessage = '';
isRunning = false;
completed = false;
async handleRun() {
if (this.isRunning || this.completed) {
return;
}
this.isRunning = true;
this.errorMessage = '';
try {
const request = MSSharePointObjects.inputs.listItem();
request.connectorId = this.connectorId;
request.siteId = 'REPLACE_WITH_SITE_ID';
request.listId = 'REPLACE_WITH_LIST_ID';
request.itemId = '12';
request.inputFields = '{"Title":"Project update"}';
const result = await updateSharePointListItem(request);
if (!result?.id) {
throw new Error('The action did not return a usable result.');
}
this.result = result;
this.completed = true;
} catch (error) {
this.errorMessage = error.requiresInteractiveAuthorization
? 'Sign in to Microsoft for the connector, then try again.'
: error.message || 'The SharePoint action failed.';
} finally {
this.isRunning = false;
}
}
}
sharePointActionExample.html
<template>
<lightning-button label="Run action" onclick={handleRun}
disabled={isRunning}></lightning-button>
<p role="alert">{errorMessage}</p>
</template>
The library resolves to one mapped resource object or null.
The controller exposes fieldsJson containing a JSON object of field values, plus flattened identity, parent, content-type, and drive-item metadata. Update List Item only supplies the returned fields and input ID; retrieve the record separately if full metadata is needed.
LWC rawJson serializes the mapped Apex object; it is not the untouched Microsoft response or an additional global invocable output. Use getMSSharePointAuthorizationState, beginMSSharePointAuthorization, and createMSSharePointOAuthMessageHandler to arrange delegated sign-in. The library normalizes controller errors, including requiresInteractiveAuthorization when available; it does not automatically sign in or retry.
The example prevents repeating a completed operation. Reset completed only for a new deliberate operation. If a failure leaves the outcome uncertain, inspect the resource before retrying. For Copy, completed means the request returned, not that the background copy finished.
Error handling and troubleshooting
| Symptom | What to check |
|---|---|
| Required fields error | Supply a nonempty request list, a non-null first request, and the required identifiers or body values. |
| Authorization or access denied | Check connector selection, sign-in, application versus delegated permissions, administrator consent, and resource access. |
| Resource not found | Verify the parent site, list, and drive IDs. Distinguish list item IDs from drive item IDs and retain permission or version IDs with their resource. |
| Missing fields or items | Check query inputs, first-page behavior, supported expansions, item type, and mapped output limitations. |
| Unexpected connector | Review the connector selection behavior described above and the Microsoft 365 default connector. |
| Operation rejected | Inspect the Microsoft error, JSON field values, library or page state, supported API capabilities, and tenant policies. |