Table of Contents

Codeunit "SharePoint Client"

ID 9100
Namespace: System.Integration.Sharepoint

Provides functionality for interacting with SharePoint REST API

Properties

Name Value
Access Public

Methods

Initialize

Initializes SharePoint client.

procedure Initialize(BaseUrl: Text, Authorization: Interface "SharePoint Authorization")

Parameters

Name Type Description
BaseUrl Text

SharePoint URL to use.

Authorization Interface System.Integration.Sharepoint."SharePoint Authorization"

The authorization to use.

Initialize

Initializes SharePoint client.

procedure Initialize(BaseUrl: Text, Namespace: Text, Authorization: Interface "SharePoint Authorization")

Parameters

Name Type Description
BaseUrl Text

SharePoint URL to use.

Namespace Text

Namespace to use.

Authorization Interface System.Integration.Sharepoint."SharePoint Authorization"

The authorization to use.

GetDiagnostics

Returns detailed information on last API call.

procedure GetDiagnostics(): Interface "HTTP Diagnostics"

Returns

Type Description
Interface System.Integration.Sharepoint."HTTP Diagnostics"

Codeunit holding http resonse status, reason phrase, headers and possible error information for tha last API call

GetLists

Gets all lists on the given site.

procedure GetLists(var SharePointList: Record "SharePoint List" temporary): Boolean

Parameters

Name Type Description
SharePointList Table System.Integration.Sharepoint."SharePoint List"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetListItems

Gets all list items for the given list.

procedure GetListItems(ListTitle: Text, var SharePointListItem: Record "SharePoint List Item" temporary): Boolean

Parameters

Name Type Description
ListTitle Text

The title of the list/

SharePointListItem Table System.Integration.Sharepoint."SharePoint List Item"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetListItems

Gets all list items for the given list.

procedure GetListItems(ListId: Guid, var SharePointListItem: Record "SharePoint List Item" temporary): Boolean

Parameters

Name Type Description
ListId Guid

The GUID of the list/

SharePointListItem Table System.Integration.Sharepoint."SharePoint List Item"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetListItemAttachments

Gets all attachments for the given list item.

procedure GetListItemAttachments(ListTitle: Text, ListItemId: Integer, var SharePointListItemAtch: Record "SharePoint List Item Atch" temporary): Boolean

Parameters

Name Type Description
ListTitle Text

The title of the list

ListItemId Integer

Unique id of the item within the list.

SharePointListItemAtch Table System.Integration.Sharepoint."SharePoint List Item Atch"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetListItemAttachments

Gets all attachments for the given list item.

procedure GetListItemAttachments(ListId: Guid, ListItemId: Integer, var SharePointListItemAtch: Record "SharePoint List Item Atch" temporary): Boolean

Parameters

Name Type Description
ListId Guid

The GUID of the list

ListItemId Integer

Unique id of the item within the list.

SharePointListItemAtch Table System.Integration.Sharepoint."SharePoint List Item Atch"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadListItemAttachmentContent

Downloads the specified attachment file to the client.

procedure DownloadListItemAttachmentContent(ListTitle: Text, ListItemId: Integer, FileName: Text): Boolean

Parameters

Name Type Description
ListTitle Text

The title of the list

ListItemId Integer

Unique id of the item within the list.

FileName Text

Name to be given to the file on the client side. Does not need to match the server side name.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadListItemAttachmentContent

Downloads the specified attachment file to the client.

procedure DownloadListItemAttachmentContent(ListId: Guid, ListItemId: Integer, FileName: Text): Boolean

Parameters

Name Type Description
ListId Guid

The GUID of the list

ListItemId Integer

Unique id of the item within the list.

FileName Text

Name to be given to the file on the client side. Does not need to match the server side name.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadListItemAttachmentContent

Downloads the specified attachment file to the client.

procedure DownloadListItemAttachmentContent(OdataId: Text): Boolean

Parameters

Name Type Description
OdataId Text

The odata.id parameter of the attachment entity.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

The server side file name will be used.

CreateListItemAttachment

Creates the list item attachment for given item.

procedure CreateListItemAttachment(ListTitle: Text, ListItemId: Integer, var SharePointListItemAtch: Record "SharePoint List Item Atch" temporary): Boolean

Parameters

Name Type Description
ListTitle Text

The title of the list.

ListItemId Integer

Unique id of the item within the list.

SharePointListItemAtch Table System.Integration.Sharepoint."SharePoint List Item Atch"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

Remarks

Requires UI interaction to pick a file.

CreateListItemAttachment

Creates the list item attachment for given item.

procedure CreateListItemAttachment(ListID: Guid, ListItemId: Integer, var SharePointListItemAtch: Record "SharePoint List Item Atch" temporary): Boolean

Parameters

Name Type Description
ListID Guid

The GUID of the list.

ListItemId Integer

Unique id of the item within the list.

SharePointListItemAtch Table System.Integration.Sharepoint."SharePoint List Item Atch"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Requires UI interaction to pick a file.

CreateListItemAttachment

Creates a list item attachment for specific list item.

procedure CreateListItemAttachment(ListTitle: Text, ListItemId: Integer, FileName: Text, var FileInStream: InStream, var SharePointListItemAtch: Record "SharePoint List Item Atch" temporary): Boolean

Parameters

Name Type Description
ListTitle Text

The title of the list.

ListItemId Integer

Unique id of the item within the list.

FileName Text

File name to use on SharePoint.

FileInStream InStream

File stream to upload.

SharePointListItemAtch Table System.Integration.Sharepoint."SharePoint List Item Atch"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Does not require UI interaction.

CreateListItemAttachment

Creates a list item attachment for specific list item.

procedure CreateListItemAttachment(ListID: Guid, ListItemId: Integer, FileName: Text, var FileInStream: InStream, var SharePointListItemAtch: Record "SharePoint List Item Atch" temporary): Boolean

Parameters

Name Type Description
ListID Guid

The GUID of the list.

ListItemId Integer

Unique id of the item within the list.

FileName Text

File name to use on SharePoint.

FileInStream InStream

File stream to upload.

SharePointListItemAtch Table System.Integration.Sharepoint."SharePoint List Item Atch"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Does not require UI interaction.

CreateList

Creates a new list.

procedure CreateList(ListTitle: Text, ListDescription: Text, var SharePointList: Record "SharePoint List" temporary): Boolean

Parameters

Name Type Description
ListTitle Text

Title for the new list.

ListDescription Text

Description for the new list.

SharePointList Table System.Integration.Sharepoint."SharePoint List"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

CreateListItem

Creates a new list item in specific list.

procedure CreateListItem(ListTitle: Text, ListItemEntityTypeFullName: Text, ListItemTitle: Text, var SharePointListItem: Record "SharePoint List Item" temporary): Boolean

Parameters

Name Type Description
ListTitle Text

The title of the list.

ListItemEntityTypeFullName Text

The Entity Type for the list. Parameter can be found on a list object (ListItemEntityType).

ListItemTitle Text

The title of the new list item.

SharePointListItem Table System.Integration.Sharepoint."SharePoint List Item"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

CreateListItem

Creates a new list item in specific list.

procedure CreateListItem(ListId: Guid, ListItemEntityTypeFullName: Text, ListItemTitle: Text, var SharePointListItem: Record "SharePoint List Item" temporary): Boolean

Parameters

Name Type Description
ListId Guid

The GUID of the list.

ListItemEntityTypeFullName Text

The Entity Type for the list. Parameter can be found on a list object (ListItemEntityType).

ListItemTitle Text

The title of the new list item.

SharePointListItem Table System.Integration.Sharepoint."SharePoint List Item"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetSubFoldersByServerRelativeUrl

Lists all subfolders in the given folder.

procedure GetSubFoldersByServerRelativeUrl(ServerRelativeUrl: Text, var SharePointFolder: Record "SharePoint Folder" temporary): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the parent folder.

SharePointFolder Table System.Integration.Sharepoint."SharePoint Folder"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Only top level subfolders are included.

GetFolderFilesByServerRelativeUrl

Lists all files in the given folder.

procedure GetFolderFilesByServerRelativeUrl(ServerRelativeUrl: Text, var SharePointFile: Record "SharePoint File" temporary): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the parent folder.

SharePointFile Table System.Integration.Sharepoint."SharePoint File"

Collection of the result (temporary record).

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetFolderFilesByServerRelativeUrl

Lists all files in the given folder.

procedure GetFolderFilesByServerRelativeUrl(ServerRelativeUrl: Text, var SharePointFile: Record "SharePoint File" temporary, ListAllFields: Boolean): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the parent folder.

SharePointFile Table System.Integration.Sharepoint."SharePoint File"

Collection of the result (temporary record).

ListAllFields Boolean

Include metadata in results.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetFileByServerRelativeUrl

Gets file data by server relative url

procedure GetFileByServerRelativeUrl(ServerRelativeUrl: Text, var SharePointFile: Record "SharePoint File" temporary, ListAllFields: Boolean): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the file.

SharePointFile Table System.Integration.Sharepoint."SharePoint File"

Collection of the result (temporary record).

ListAllFields Boolean

Include metadata in results.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadFileContent

Downloads a file to an InStream.

procedure DownloadFileContent(OdataId: Text, var FileInStream: InStream): Boolean

Parameters

Name Type Description
OdataId Text

The odata.id parameter of the file entity.

FileInStream InStream

The InStream that will be populated with the file content.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadFileContent

Downloads a file to the client.

procedure DownloadFileContent(OdataId: Text, FileName: Text): Boolean

Parameters

Name Type Description
OdataId Text

The odata.id parameter of the file entity.

FileName Text

Name to be given to the file on the client side. Does not need to match the server side name.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadFileContent

Downloads a file to a TempBlob.

procedure DownloadFileContent(OdataId: Text, var TempBlob: Codeunit "Temp Blob"): Boolean

Parameters

Name Type Description
OdataId Text

The odata.id parameter of the file entity.

TempBlob Codeunit System.Utilities."Temp Blob"

The TempBlob that will be populated with the file content.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadFileContentByServerRelativeUrl

Downloads a file to an InStream.

procedure DownloadFileContentByServerRelativeUrl(ServerRelativeUrl: Text, var FileInStream: InStream): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the file to Download.

FileInStream InStream

The InStream that will be populated with the file content.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadFileContentByServerRelativeUrl

Downloads a file to the client.

procedure DownloadFileContentByServerRelativeUrl(ServerRelativeUrl: Text, FileName: Text): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the file to Download.

FileName Text

Name to be given to the file on the client side. Does not need to match the server side name.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DownloadFileContentByServerRelativeUrl

Downloads a file to a TempBlob.

procedure DownloadFileContentByServerRelativeUrl(ServerRelativeUrl: Text, var TempBlob: Codeunit "Temp Blob"): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the file to Download.

TempBlob Codeunit System.Utilities."Temp Blob"

The TempBlob that will be populated with the file content.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DeleteFile

Deletes a file.

procedure DeleteFile(OdataId: Text): Boolean

Parameters

Name Type Description
OdataId Text

The odata.id parameter of the file entity.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DeleteFileByServerRelativeUrl

Deletes a file.

procedure DeleteFileByServerRelativeUrl(ServerRelativeUrl: Text): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the file to delete.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

GetDocumentLibraryRootFolder

Gets root folder for the list entity (Document Library).

procedure GetDocumentLibraryRootFolder(OdataID: Text, var SharePointFolder: Record "SharePoint Folder" temporary): Boolean

Parameters

Name Type Description
OdataID Text
SharePointFolder Table System.Integration.Sharepoint."SharePoint Folder"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

See "Is Catalog" parameter of the list.

CreateFolder

Creates a new folder.

procedure CreateFolder(ServerRelativeUrl: Text, var SharePointFolder: Record "SharePoint Folder" temporary): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the new folder.

SharePointFolder Table System.Integration.Sharepoint."SharePoint Folder"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Create subfolders by manipulating URL.

FolderExistsByServerRelativeUrl

Checks if a folder exists.

procedure FolderExistsByServerRelativeUrl(ServerRelativeUrl: Text): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the folder to check.

Returns

Type Description
Boolean

True if the folder exists; otherwise - false.

DeleteFolder

Deletes a folder.

procedure DeleteFolder(OdataId: Text): Boolean

Parameters

Name Type Description
OdataId Text

The odata.id parameter of the folder entity.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

DeleteFolderByServerRelativeUrl

Deletes a folder.

procedure DeleteFolderByServerRelativeUrl(ServerRelativeUrl: Text): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the folder to delete.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

AddFileToFolder

Adds a file to specific folder.

procedure AddFileToFolder(ServerRelativeUrl: Text, var SharePointFile: Record "SharePoint File" temporary): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the parent folder.

SharePointFile Table System.Integration.Sharepoint."SharePoint File"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Requires UI interaction to pick a file.

AddFileToFolder

Adds a file to specific folder.

procedure AddFileToFolder(ServerRelativeUrl: Text, var SharePointFile: Record "SharePoint File" temporary, ListAllFields: Boolean): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the parent folder.

SharePointFile Table System.Integration.Sharepoint."SharePoint File"

Collection of the result (temporary record). Always one element.

ListAllFields Boolean

Include metadata in results.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Requires UI interaction to pick a file.

AddFileToFolder

Adds a file to specific folder.

procedure AddFileToFolder(ServerRelativeUrl: Text, FileName: Text, var FileInStream: InStream, var SharePointFile: Record "SharePoint File" temporary): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the parent folder.

FileName Text

File name to use on SharePoint.

FileInStream InStream

File stream to upload.

SharePointFile Table System.Integration.Sharepoint."SharePoint File"

Collection of the result (temporary record). Always one element.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Does not require UI interaction.

AddFileToFolder

Adds a file to specific folder.

procedure AddFileToFolder(ServerRelativeUrl: Text, FileName: Text, var FileInStream: InStream, var SharePointFile: Record "SharePoint File" temporary, ListAllFields: Boolean): Boolean

Parameters

Name Type Description
ServerRelativeUrl Text

URL of the parent folder.

FileName Text

File name to use on SharePoint.

FileInStream InStream

File stream to upload.

SharePointFile Table System.Integration.Sharepoint."SharePoint File"

Collection of the result (temporary record). Always one element.

ListAllFields Boolean

Include metadata in results.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Remarks

Does not require UI interaction.

UpdateListItemMetaDataField

Updates metadata field for list item.

procedure UpdateListItemMetaDataField(ListTitle: Text, ItemId: Integer, ListItemEntityTypeFullName: Text, FieldName: Text, FieldValue: Text): Boolean

Parameters

Name Type Description
ListTitle Text

The title of the list.

ItemId Integer

The GUID of the item.

ListItemEntityTypeFullName Text

The Entity Type for the list. Parameter can be found on a list object (ListItemEntityType).

FieldName Text

The name of the metadata field.

FieldValue Text

Value.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

UpdateListItemMetaDataField

Updates metadata field for list item.

procedure UpdateListItemMetaDataField(ListId: Guid, ItemId: Integer, ListItemEntityTypeFullName: Text, FieldName: Text, FieldValue: Text): Boolean

Parameters

Name Type Description
ListId Guid

The GUID of the list.

ItemId Integer

The GUID of the item.

ListItemEntityTypeFullName Text

The Entity Type for the list. Parameter can be found on a list object (ListItemEntityType).

FieldName Text

The name of the metadata field.

FieldValue Text

Value.

Returns

Type Description
Boolean

True if the operation was successful; otherwise - false.

Events

ProcessSharePointFileMetadata

[IntegrationEvent(False,False)]
internal procedure ProcessSharePointFileMetadata(Metadata: JsonToken, var SharePointFile: Record "SharePoint File" temporary)

Parameters

Name Type Description
Metadata JsonToken
SharePointFile Table System.Integration.Sharepoint."SharePoint File"

ProcessSharePointListItemMetadata

[IntegrationEvent(False,False)]
internal procedure ProcessSharePointListItemMetadata(Metadata: JsonToken, var SharePointListItem: Record "SharePoint List Item" temporary)

Parameters

Name Type Description
Metadata JsonToken
SharePointListItem Table System.Integration.Sharepoint."SharePoint List Item"

See also