1

I need to updated millions of records which is of currency type.So i need to write business logic for the same.So shall i go with trigger or Batch class. In the case of a trigger, every time an invoice record is added, deleted or modified Amount will be recalculated.While in case of batch class,records will be updated based on a process that can be scheduled to run on a specific day and time of the month.

1
  • 1
    okay, so what is your question?
    – Novarg
    Jun 24 '16 at 8:30
2

It depends on what you are doing.

If this is a onetime update: write a batch that fixes all of your records.

If this is a recurring thing: write a batch that fixes all of your records and then write a trigger to do that for every new record that will be created.

2
  • So i have to write both trigger and batch class to update smoothly.It is a recurring thing.I think only batch class will work fine.No need to write trigger on creation of records as batch will update that record also.
    – Jack vardy
    Jun 24 '16 at 8:36
  • 1
    Yes. I'm assuming (because you didn't say) that you create a new field and this needs to get a value one way or another. To do this the first time you can write your batch that queries all relevant records, makes the calculation, and updates the record. To make sure that your data will keep up to date (new records being inserted) create a trigger that does the calculation on insert / update. Then you run the batch once, and in the future the trigger makes sure that the batch is not needed anymore.
    – Nielsm
    Jun 24 '16 at 8:39
1

We have recently released a new salesforce App called Rubrik which may help you with your updates. Rubrik is used to do mass update/creation/deletion of records based on user defined criteria. We know making mass changes can be scary, so there is the ability to preview the changes before fully committing them to the database. There is also a functionality to use Rubrik as a trigger, to process records as they are inserted/updated. This allows Administrators to do tasks that would usually require a developer.

In your case, you could use Rubrik to update your million of records one time and then set up Rubrik as a trigger to process any new records after.

You can learn more here: Rubrik Features

To try out Rubrik, please go to here: Free Trial

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.