Skip to main content

I created a custom object called 'Shipping Rates' with fields; 

Effective Date, Minimum, Maximum, and Rate. Here is an example table:

Effective Date Minimum Maximum Rate

1/1/23 100,000 infinite 100

1/1/23 50,000 100,000 75

1/1/23 25,000 50,000 50

1/1/23 0 25,000 25

1/1/22 100,000 infinite 80

1/1/22 50,000 100,000 60

1/1/22 25,000 50,000 40

1/1/22 0 25,000 20

Ideally, if I could sort by effective date and minimum and get only the first result, I would not need the maximum field at all. In SQL that would look like:

SELECT rate WHERE minimum < quote.total SORT BY effective date DESC, minimum DESC LIMIT 1

The problem is when I start building flows, I can only sort by one field in the get records, so I have to store all records instead of only the first record. But when I store all records, I cannot use the GetRate.Rate variable in the calculation.

 

Edit: to use a sort collection I have to store both effective date and minimum fields. But I also have to add 'additional shipping' to the shipping rate. I cant seem to pull the result of the collection sort into a formula variable to add the two together.

 

Is there a way to get only the first record sorted by effective date and minimum?

5 answers
  1. Eric Praud (Activ8 Solar Energies) Forum Ambassador
    Dec 5, 2022, 7:39 PM

    Once you have used the Sort Collection, you would need to loop over your Get Record variable.

    Here's an example on how to do it:

    https://www.youtube.com/watch?v=92Kktu9Yl68&ab_channel=SalesforceGeek

0/9000