Copying Rates Through Automation or Code

AdvoLogix provides the ability to automate the process of copying rates via Apex code or through automation. The Process Builder action allows organizations to create processes to copy rates within the visual workflow designer while our Apex class supports a variety of custom integration solutions by allowing organizations to deploy rates within a variety of use cases.

Copy Rates with Process Builder

The following technique has been developed to provide organizations with the ability to automatically copy rates from within the Process Builder.

To use this class in Process Builder, follow these steps as highlighted below:

  1. Go to Setup | Create | Workflows  Approvals | Process Builder, and Create a New Process and click Add Action.

  2. Select Action Type as Apex. Enter Action Name. This is your way of identifying the action in the list of actions.

  3. Select Copy Rates as Apex Class.

  4. Enter the To Matter ID for the Matter you wish to copy the rates to.

  5. Click Add Row, and select From Matter ID and/or From Rate Group ID.

  6. Optionally, click Add Row, and select Matter ID field. Select the Matter ID as the reference field from the field picker dialog.

  7. Optionally, click Add Row, and select Copy Default Flag when the process should copy the Default Rate setting from the source rates.

  8.  Click Save.

NOTE: You will normally copy rates either from an existing matter or from a rate group.  In doing so you would supply either a source Matter or a source Rate Group. It is possible to supplying both parameters (fromMatterID and fromRateGroupID) in this case. When both parameters are provided, only the subset of rates which exist in both sources are copied to the target matter.

Coping Rates Via Code

The following Apex method can be used to copy rates via custom coding. Please be aware this method requires knowledge of Force.com best practices and as always we suggest testing your code in the Sandbox.

Syntax:

RatesService.copyRates(
  @fromMatterID,
  @fromRateGroupID,
  @toMatterID,
  @copyDefaultFlag
);

Parameters:

@fromMatterID 

The source Matter ID to be used to copy rates from. Optional when using fromRateGroupID (see note for more information).

@fromRateGroupID 

The source Rate Group ID to be used to copy rates from. Optional when using fromMatterID (see note for more information).

@toMatterID 

Required: The target Matter ID to copy rates to.

@copyDefaultFlag

When set to ‘true’ will copy the default rate flag from the source rate. Otherwise the Rate's Default setting will be set to unchecked.

Result:

The function call will return a JSON formatted string in this format: {success:"",result:""}

success

Will be either TRUE or FALSE

result

Text confirmation of success or error (if the process is halted by an unexpected error).

Example:

RatesService.copyRates(
   'a0b9000000RJhKT',
   'a1C4000000GJgrh',
   'a0b9000000PTgaF',
   false
);