OneDrive/SharePoint — Move
OneDrive/SharePoint — Move
Section titled “OneDrive/SharePoint — Move”Type: msfiles-move · Package: OneDrive / SharePoint v1.0.5 · Output: Dictionary<string,object>
Moves a file or folder to another folder in the drive and can rename it at the same time. The item keeps its ID, version history and sharing permissions; only its location changes (and its name, if you give one). It is the natural way to archive what has been processed.
How it works
Section titled “How it works”It works on the session created with OneDrive/SharePoint — Connect. Pass it in the session parameter, or place this activity inside the body of Connect to inherit it automatically.
Give the item by its id and the target folder with folderId. To rename it in the same step, use name. To only rename, pass as folderId the folder it is already in (info["parentId"] from Get info).
Keep in mind:
- The operation is immediate and the target folder must be in the session’s drive.
- If an item with the same name already exists at the target, Microsoft 365 rejects the move (it does not overwrite). Use
nameto give it a different one. - Moving it again to the folder it is already in changes nothing.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | ID of the item to move. |
folderId | string | — | Target folder ID. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanMicrosoftFilesSession | — | Connect session. Inherited inside Connect’s body. |
name | string | — | New name, with extension. When omitted, the current name is kept. |
Output
Section titled “Output”Returns a Dictionary<string,object> with the item’s updated data: id (same as before), name, isFolder, size, webUrl (the new address), parentId (the target folder), modifiedTime, createdTime and childCount.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
No OneDrive/SharePoint session available. Provide 'session' from an msfiles-connect activity, or place this activity inside the Connect activity's body so the session is inherited automatically. | The activity is outside Connect’s body and did not receive session. Place it inside the body or pass session = session. |
'id' is required. / 'folderId' is required. | The parameter is empty or its expression returned null. |
itemNotFound (Microsoft Graph, 404) | The item or the target folder does not exist in the session’s drive. |
nameAlreadyExists (Microsoft Graph, 409) | An item with that name already exists in the target folder. Give another name (for example, with the date). |
invalidRequest (Microsoft Graph, 400) | The new name has characters that are not allowed, or you tried to move a folder into itself. |
Example
Section titled “Example”Archive a processed report with the date in its name:
OneDrive/SharePoint — Connect credential = credential("m365-operations") └─ body: OneDrive/SharePoint — Move id = reportId folderId = processedFolderId name = "Processed " + DateTime.Now.ToString("yyyy-MM-dd") + ".pdf" → output: moved Log message = "Archived at " + moved["webUrl"]Related activities
Section titled “Related activities”- OneDrive/SharePoint — Copy — copy instead of move.
- OneDrive/SharePoint — Create folder — create the target folder.
- OneDrive/SharePoint — List files — find the IDs.
- All OneDrive / SharePoint activities