AdvoLogix provides a wide range of Apex invocable methods that allow you to easily execute different SharePoint-related actions as part of your flow, process builder, or from an Apex class.
List of Available Apex Invocable Methods
There are many different SharePoint-related actions that can be automated with the AdvoLogix Connector for SharePoint and Salesforce. Here you can find the list of all available Apex methods:
- Create Folder (SharePointFolderInvocableAction)
- Upload Document (SharePointFileUploadService)
Adding an Apex method to a flow is a very simple task. You just need to drag and drop or add an Action item into the Flow Builder canvas. If you filter the actions by Category and select the SharePoint Connector, you will find all AdvoLogix-provided Apex actions available under the Action lookup field.
The detailed usage of the above mentioned Apex actions is outlined below:
Drag and drop or add an Action item in the Flow Builder canvas. Filter the actions by Category, select the SharePoint Connector, and select Create Folder under the Action lookup field.
Input Values
- Salesforce Record ID - Provide the current record's record ID value here.
- Folder Name - Provide the new folder's name.
- Library and Folder Path - [optional] Provide the relative path between the SharePoint Site and the location where your new folder is to be created.
- Site Address - [optional] Provide the SharePoint Site Address. (See how to retrieve SharePoint Site Address)
- Folder Template Id - [optional] Provide a folder template's record ID value here, which will be used to generate a sub-folder structure within the new folder created here.
- Login As User ID - [optional] Provide a user ID (that is enabled as a Secured Logins user) to automatically authenticate your SharePoint-related operations within this flow action. (For more details about this Apex Action, see this article.)
- Use Asynchronous Method - Provide a true/false value to indicate that this process is to be executed as an asynchronous approach.
When the Use Asynchronous Method is True, the Output Value for the SharePoint Folder is returned as null.
Library and Folder Path should always start with your document library name. By default, all SharePoint sites have a shared document library named Shared Documents. If your administrator has created other document libraries then you may enter any other document library name here along with your path to the newly created folder.
For example:
USE CASE 1:
Considering your administrator has created a private library named as Firm Documents and the library contains a folder named All Firm Contracts, and your new folder must be created within this folder only, then your Library and Folder Path may be set up as:
- Firm Documents/All Firm Contracts
USE CASE 2:
Considering your administrator wants to use the default document library and the library contains a folder named All Firm Contracts and that your new folder must be created within this folder only, then your Library and Folder Path may be set up as:
- Shared Documents/All Firm Contracts
Output Values
When the Folder has been created successfully, this method will return apex data-type variable output. The response will contain values such as the SharePoint Unique Folder Id, Folder Name and Folder Relative URL or error messages in case of errors.
Salesforce does not allow Rest API executions or DML operations, such as inserting or updating Salesforce records in a single transaction. In these cases, Salesforce alerts the user with the error 'You have uncommitted work pending. Please commit or rollback before calling out'. In situations where this error occurs, AdvoLogix advises users to set the Use Asynchronous Method to True.
Example Apex script:
shpoint.SharePoint.SharePointFolderRequest req1 = new shpoint
.SharePoint.SharePointFolderRequest();
req1.recordId = '0010C00000WxO5fUAF';
req1.useAsynchronousMethod = false;
shpoint
.SharePoint.SharePointFolderRequest[] reqList = new shpoint
.SharePoint.SharePointFolderRequest{ req1 };
shpoint
.SharePoint.SharePointFolderResponse[] resp = shpoint
.SharePointFolderInvocableAction.createFolder( reqList );
system.debug('Create Folder Response :: '+resp[0]);
Drag and drop or add an Action item in the Flow Builder canvas. Filter the actions by Category, select SharePoint Connector, and select Upload Document under the Action lookup field.
Input Values
- Content Version ID - Provide the Salesforce File record's record ID value here.
- Salesforce Record ID - Provide the current record's record ID value here.
- Folder Path - [optional] Provide the path to the folder that should already exist within your SharePoint site. If left empty, the document will be saved to the root of the mapped folder found for the Salesforce Record.
- Site Address - [optional] Provide the SharePoint Site Address. (See how to retrieve SharePoint Site Address)
- Login As User ID - [optional] Provide a user id (that is enabled as a Secured Logins user) to automatically authenticate your SharePoint-related operations within this flow action. (For more details about this Apex Action, see this article.)
- Use Asynchronous Method - Provide a true/false value to indicate that this process is to be executed as an asynchronous approach.
When the Use Asynchronous Method is True, then the Output Value for the SharePoint Upload Document is returned as null.
Output Values
Upon successful execution of this method, the apex data-type variable output will be returned. The response will contain values such as Document Relative URL, Document Name, Document Unique ID, and error details when an error occurs in the uploading process.
Salesforce does not allow Rest API executions or DML operations, such as inserting or updating Salesforce records in a single transaction. In these cases, Salesforce alerts the user with the error 'You have uncommitted work pending. Please commit or rollback before calling out'. In situations where this error occurs, AdvoLogix advises users to set the Use Asynchronous Method to True.
Example Apex script:
shpoint.SharePointFileUploadService.FileUploadWrapper req1 = new shpoint
.SharePointFileUploadService.FileUploadWrapper();
req1.contentVersionId = '0690D00000WxO2fAAA';
req1.recordId = '0010D00000TxO1cAAA
';
req1.userId = UserInfo.getUserId();
req1.folderName = 'Test folder';
shpoint
.SharePointFileUploadService.FileUploadWrapper[] reqList = new shpoint
.SharePointFileUploadService.FileUploadWrapper{ req1 };
shpoint
.SharePointFileUploadService.FileUploadFlowResponse[] resp = shpoint
.SharePointFileUploadService.uploadDocument( reqList );
system.debug('Uploaded Document in SharePoint Response :: '+resp[0]);