AdvoLogix Matter Management

Apex Invocable Methods Available Within the Connector

Updated

AdvoLogix® provides a wide range of Apex invocable and global methods that allow you to easily execute different iManage® related actions as part of your flow, process builder, or from an Apex class.

List of Available Apex Invocable Methods

There are many different iManage® related actions that can be automated with the AdvoLogix® Connector for iManage® and Salesforce®. Here is a list of all available Apex methods: 

  • Create Workspace (iManageServiceCreateWorkspace)
  • Update Workspace (iManageServiceUpdateWorkspace)
  • Find Workspaces (iManageServiceLookupWorkspace)
  • Upload Document (iManageServiceUploadDocument)
  • Merge Workspaces (iManageServiceGlobal.mergeWorkspaces)

Adding an Apex method to a flow is a very simple task. 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.  Filter the actions by Category, select the iManage Connector, and select Create Workspace under the Action lookup field.

Create Workspace
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 iManage Connector, and select Create Workspace under the Action lookup field.

Input Values
  • Record ID - Provide the current record's record Id value here.
  • iManage Library - (optional) Provide an iManage library name.
  • Login As User ID - (optional) Provide a user id to automatically authenticate all iManage Work related operations within this flow action. The provided user must be enabled as a Secured Login within iManage Setup. For more details, see this article.
  • Use Asynchronous Method - Provide a true/false value to mark this process to be executed as an asynchronous approach.

When Use Asynchronous Method is true, then the output value for the iManage Workspace is returned as null.

Output Values

When the Workspace has been created successfully, this method will return an iManage Workspace apex data-type variable output. The response will contain values such as workspace id and workspace name, along with all custom profile data values and descriptions.

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:

imanage.iManageServiceCreateWorkspace.Request req1 = new imanage.iManageServiceCreateWorkspace.Request();
req1.recordId = '0010C00000WxO5fUAF';
req1.useAsynchronousMethod = false;
imanage.iManageServiceCreateWorkspace.Request[] reqList = new imanage.iManageServiceCreateWorkspace.Request{ req1 };

imanage.iManageServiceCreateWorkspace.Response[] resp = imanage.iManageServiceCreateWorkspace.process( reqList );
system.debug('Create Workspace Response :: '+resp[0]);
Update Workspace

This action method requires old and new record field values to work appropriately, and thus must be used when the flow is executing as a record-triggered update event.

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 iManage Connector and Update Workspace under the Action lookup field.

Select Objects
  • Object for "SObject Record (New)" (Input) - Select an object in which the current flow is set to be triggered from.
  • Object for "SObject Record (Old)" (Input) - Select an object in which the current flow is set to be triggered from.
Input Values
  • SObject Record (New) - Provide the record object/variable that stores the data of the record that has been changed. (Normally it will be {!$Record} variable)
  • SObject Record (Old) - Provide the Record object/variable that stores the data of the record that was saved in the database before the new changes. (Usually it should be {!$Record__Prior} variable)
  • iManage Library - Optionally, provide an iManage library name.
  • Login As User ID - Optionally, provide a user id to automatically authenticate all iManage Work related operations within this flow action. The provided user must be enabled as Secured Login within iManage Setup. For more details follow 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 iManage Workspace is returned as null.

Output Values

When the Workspace name has been changed successfully, this method will return an iManage Workspace apex data-type variable output. The response will contain values such as workspace id and workspace name, along with all the custom profile data values and descriptions.

Salesforce does not allow Rest API executions and DML operations such as inserting, updating Salesforce records in single transaction. In these cases Salesforce alerts user with an 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:

imanage.iManageServiceUpdateWorkspace.Request req1 = new imanage.iManageServiceUpdateWorkspace.Request();
req1.sObject_NewRecord = new Account(Id='0010C00000WxO5fUAF', Name='Test Account New Name');
req1.sObject_OldRecord = new Account(Id='0010C00000WxO5fUAF', Name='Test Account Old Name');
req1.useAsynchronousMethod = false;
imanage.iManageServiceUpdateWorkspace.Request[] reqList = new imanage.iManageServiceUpdateWorkspace.Request{ req1 };

imanage.iManageServiceUpdateWorkspace.Response[] resp = imanage.iManageServiceUpdateWorkspace.process( reqList );
system.debug('Update Workspace Response :: '+resp[0]);
Find Workspaces
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 the iManage Connector and select Find Workspace under the Action lookup field.

Input Values
  • Record ID - Provide the current record's record Id value here.
  • Login As User ID - Optionally, provide a user id to automatically authenticate all iManage Work related operations within this flow action. The provided user must be enabled as Secured Login within iManage Setup. For more details follow this article.
Output Values

On successful execution of the method, it will return the List of iManage Workspaces apex data-type variable output that has been identified as associated with the Salesforce record. Each workspace item in the response will contain values such as workspace id and workspace name, along with all custom profile data values and descriptions.

This method auto-validates whether Workspace Manager Configuration exists and is active for the object this record belongs to. If an active configuration is not found, then this method returns no workspaces associated with the record.

Using the Apex Method in an Apex Class

Example Apex script:

imanage.iManageServiceLookupWorkspace.Request req1 = new imanage.iManageServiceLookupWorkspace.Request();
req1.recordId = '0010C00000WxO5fUAF';
imanage.iManageServiceLookupWorkspace.Request[] reqList = new imanage.iManageServiceLookupWorkspace.Request{ req1 };

imanage.iManageServiceLookupWorkspace.Response[] resp = imanage.iManageServiceLookupWorkspace.process( reqList );
system.debug('All Found Workspaces For the Record :: '+resp[0].workspaces);
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 iManage 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.
  • iManage Folder Name - Provide the name of the folder, which already exists within the workspace provided in the iManage Workspace input.
  • iManage Library - Provide an iManage library name.
  • iManage Workspace - Provide an iManage workspace id.
  • iManage Document ID - Optionally, provide an existing document's Id from iManage, using with this method will upload the Salesforce File to iManage as a new version of that document.
  • Login As User ID - Optionally, provide a user id to automatically authenticate all iManage Work related operations within this flow action. The provided user must be enabled as Secured Login within iManage Setup. For more details follow this article.
Output Values

On successful execution of this method, it will return the iManage Document apex data-type variable output. The response will contain values such as document id, document name, webview url, workspace name etc.

Using the Apex Method in an Apex Class

Example Apex script:

imanage.iManageServiceUploadDocument.Request req1 = new imanage.iManageServiceUploadDocument.Request();
req1.contentVersionId = '0690D00000WxO2fAAA';
req1.library = 'Active';
req1.workspaceId = 'Active!20213';
req1.folderName = 'Test folder';
imanage.iManageServiceUploadDocument.Request[] reqList = new imanage.iManageServiceUploadDocument.Request{ req1 };

imanage.iManageServiceUploadDocument.Response[] resp = imanage.iManageServiceUploadDocument.process( reqList );
system.debug('Uploaded Document in iManage Response :: '+resp[0].document);
Merge Workspaces

The merge workspaces operation from AdvoLogix will associate all linked workspaces for merged records to the master record that remains in the organization after the records merge.

Merge Workspaces method is only available as  a global method to be consumed within Apex Triggers, since Salesforce Merge operation requires very specific execution points that Salesforce Flows® do not support yet.

Using the Apex Method in an Apex Trigger

To support the merge workspaces operation for any object that can be merged in Salesforce, your administrator or developer must first create an Apex Trigger on that object with an after delete entry point. 

Syntax:
iManageServiceGlobal.mergeWorkspaces(
    @mergedRecordsJSONString,
    @loginAsUserId,
);

Parameters:
@mergedRecordsJSONString
Provide a list of all merged records (excluding master record) as JSON serialized string.

@loginAsUserId
Provide current user's Id or a secured login enabled user's Id to authenticate the iManage specific API executions. (Pass null to use current logged in user's iManage authentication context.)


The merge workspaces operation is only supported when the method is activated from the context of an after delete Apex trigger.

If after merge the user decides to restore the merged (deleted) records from the recycle bin, then your iManage workspaces will not be relinked back to those records.  That must be done manually by the user.

Example Apex trigger:

trigger AccountMergeTrigger on Account (after delete) {    
     if (trigger.isAfter && trigger.isDelete) {        
          iManageServiceGlobal.mergeWorkspaces( JSON.serialize(trigger.old), UserInfo.getUserId() ); 
     }
} 

When the iManage Library name is provided within an Apex action, all iManage® Work related operations are executed within the provided library, otherwise we base the operations from the library provided from Workspace Manage Configuration for the object.

When a Login As user is provided within the app builder deployment options, all operations related to iManage Work are performed on behalf of that selected user. The current user cannot log in or log out from iManage Work from within the component. 

If the provided secured logged in user logs out from their environment, then the user is logged out from all instances of the components where the secured login has been setup to use as via the Login As option.

Previous Article Navigation Options for Workspaces & Folders
Next Article AdvoLogix® Connector for iManage® and Salesforce® Release Notes
Still need help? Contact Us