AdvoLogix Help

Apex Invocable Methods Available Within the Connector

Updated on

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:

Create Folder
Using the Apex Method in a Salesforce Flow

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 SharePoint Site and to where your new folder is to be created in.
  • 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 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 mark that this process is to be executed as an asynchronous approach.

When Use Asynchronous Method is True, then 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 as All Firm Contracts and that your new folder must be created within this folder only, then your Library and Folder Path may be setup as:

  • Firm Documents/All Firm Contracts

USE CASE 2:

Considering your administrator want to use the default document library and the library contains a folder named as All Firm Contracts and that your new folder must be created within this folder only, then your Library and Folder Path may be setup 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 Use Asynchronous Method to True.

Using the Apex Method in an Apex Class

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]);
Upload Document
Using the Apex Method in a Salesforce Flow

Drag and drop or add an Action item in the Flow Builder canvas. Filter the actions by Category and 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 which should already exists 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 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 mark that this process is to be executed as an asynchronous approach.

When Use Asynchronous Method is True, then the Output Value for the SharePoint Upload Document is returned as null.

Output Values

On successful execution of this method, it will return the apex data-type variable output. The response will contain values such as Document Relative URL, Document Name, Document Unique Id and error details when error occurs in 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 Use Asynchronous Method to True.

Using the Apex Method in an Apex Class

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]);
Previous Article How do I auto-upload Salesforce Files to a SharePoint Folder via automation?
Next Article [START HERE]☞Integration Guide
Still need help? Click here!
AdvoLogix® is a registered trademark of AdvoLogix.com LLC a Texas Limited Liability Company. All references to other trademarks belonging to third parties that appear on this website, documentation, or other materials shall be understood to refer to those registered trademarks owned by others, and not to any trademark belonging to AdvoLogix. Otherwise, all material herein is the copyright of AdvoLogix.com LLC. All Rights Reserved.