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:
- Go to Setup | Create | Workflows Approvals | Process Builder, and Create a New Process and click Add Action.
- Select Action Type as Apex. Enter Action Name. This is your way of identifying the action in the list of actions.
- Select Copy Rates as Apex Class.
- Enter the To Matter ID for the Matter you wish to copy the rates to.
- Click Add Row, and select From Matter ID and/or From Rate Group ID.
- Optionally, click Add Row, and select Matter ID field. Select the Matter ID as the reference field from the field picker dialog.
- Optionally, click Add Row, and select Copy Default Flag when the process should copy the Default Rate setting from the source rates.
- 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
);