0

I need to update the fields of a few records (around 20) that were existing before I made a trigger. I know that before triggers cannot update existing records (or can they ?) but I think that using batch apex for such a small number of records may not be the best solution. Is there a different way to update these records or do I still need to use a batch ?

  • I would simply use Workbench to export the data in the form of CSV, then update the data manually(considering your number of records is pretty less) on the spreadsheet and perform a update from the Workbench again. As @sfdcfox mentioned, you could also do a simple anonymous script. – Arnold Jr. Mar 15 at 13:57
0

It depends on if it is before insert or before update. If it is only before insert, you will need to manually update the records. If it is before update, you can usually just run an execute anonymous script:

update [select id from objecttype where somefield = null];
  • this worked perfectly for the issue I got ! thanks again ! – tiph Mar 15 at 14:14
0

1) Yes, You can update the existing records on same object trigger. You need to make sure the trigger do not convert on recursive mode.

2) Batch calss is npt a good solution to do DML for small number of records but you can use asynch call to do the process.

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