Updating DatedConversionRate sObject using Workbench REST API Explorer

Hello, and welcome to Another Salesforce Blog! Here I will be posting solutions to problems that I couldn’t find an answer to in hopes of helping those who find themselves stuck when using the Salesforce platform.

User Story

It’s the end of the fiscal year, and we need to update our currency conversion rates to the most recent rates. The rates are contained in a spreadsheet that was given to us by our financial team. We are unable to add a connected app due to business requirements. We must update existing DatedConversionRate objects. Multiple Currencies and Advanced Currency Management are already turned on, and currencies are already set up for the required IsoCodes.

Background

This is a continuation of my previous post, Inserting DatedConversionRate sObject using Workbench REST API Explorer. If you’ll remember, we’re updating Advanced Currency Management objects because it’s the end of the fiscal year, and we have updated numbers. We will be updating the object using the REST API Explorer in Workbench.

This method can also be used to update other Advanced Currency Management sObjects, such as the CurrencyType sObjects, as well as other sObjects that are without DML functions in Salesforce.

Documentation for this process can be found here.

Solution

Because we were given the conversion rates in an Excel spreadsheet, first we must generate a JSON to update the DatedConversionRate object. The required fields are “Id” and “ConversionRate,” and the “type” must be specified as the sObject API Name, “DatedConversionRate.”

This can be generated using the “CONCATENATE” function in Excel:

=CONCATENATE("{'attributes' : {'type' : 'DatedConversionRate'},
'Id' : '", G2, "',
'ConversionRate' : '", F2, "'}")

As in the previous post, we are using single quotations here, that will be found and replaced in VSCode to format properly.

Once the JSON code is generated, copy it into your preferred code editor, find and replace single quotes with double quotes, and preface it with the following case-sensitive parameters:

{
   "allOrNone" : "true",
   "records" : [
...

The optional “allOrNone” parameter specifies whether to roll back the entire request if there are any errors. For this purpose, we set it to “true.” The “records” parameter specifies the records to be updated.

The resulting code will look something like this:

Save your file, and select and copy its entire contents. Open your Workbench in the proper environment, and specify a URI of:

/services/data/v46.0/composite/sObjects

Paste your JSON into the Request Body, and hit Execute.

This will update the specified objects as long as there are no errors.


Thanks for reading, let me know if you have any comments or questions!

-Evelyn, Another Salesforce Blog

This image has an empty alt attribute; its file name is cropped-color-logo-no-background-1.png

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: