Skip to content

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.

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 name to give it a different one.
  • Moving it again to the folder it is already in changes nothing.
ParameterTypeDefaultDescription
idstring—ID of the item to move.
folderIdstring—Target folder ID.
ParameterTypeDefaultDescription
sessionZoanMicrosoftFilesSession—Connect session. Inherited inside Connect’s body.
namestring—New name, with extension. When omitted, the current name is kept.

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.

MessageCause 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.

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"]