AdvoLogix Help

Apex Invocable Methods Available Within the Connector

Updated

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.
  • Root Folder Path - (optional) Provide root folder path where the new folder is to be created in.
  • 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. 
  • 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.

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.
  • User ID - Provide a user id to automatically authenticate SharePoint API related operations within this flow action.
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.

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 1a - Web Application Registration (SharePoint Add-in)
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.