Salesforce Developer Tutorial - How to Mass Delete Records using Apex

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024

ความคิดเห็น • 11

  • @CodingWithTheForce
    @CodingWithTheForce  ปีที่แล้ว +8

    Make sure prior to mass deleting records that this is your employers desired end state for these records, and that they wouldn't prefer to archive/offload them to another system!

  • @sagarr7940
    @sagarr7940 8 หลายเดือนก่อน

    Very clean and clearly explained. Thanks for your inputs 🙏

  • @cassioorsi
    @cassioorsi ปีที่แล้ว +1

    Good stuff.
    I got kinda confused when you queried for the records and then deleted them.
    I thought the enqueue afterwards wouldn't work because in my head the list of cases would be empty after they got deleted.
    But in reality the original list in memory still holds the copies of the records.

  • @pedroprada1
    @pedroprada1 ปีที่แล้ว +2

    great video.. you are a natural... thank you!

  • @robinkorver7756
    @robinkorver7756 ปีที่แล้ว +1

    Any suggestions on how to handle any related records that also need deleting? (In a composable/scalable way, hopefully preventing hardcoding)

    • @DanielSoileau
      @DanielSoileau ปีที่แล้ว

      Hard to answer without knowing the org/requirements. I think you'd want some level of hard coded definition of what you're trying to delete, so it doesn't run rampant. If you have multiple objects with similar requirements, you could make the code generic (with safe guards) and pass in the target object/age (with safe guards) as a parameter to use in a dynamic query during each run. Or you can delete the children before deleting the parent all in the same transaction's execute, just watch the DML limit if spanning multiple objects in large batches. You can also consider using the build in cascade delete feature of the master/detail or lookup relationship fields to handle cleanup.

  • @IlaNaveen
    @IlaNaveen ปีที่แล้ว

    We can also use flows to delete the records.

    • @DanielSoileau
      @DanielSoileau 10 หลายเดือนก่อน

      I wanted to use flow, but unfortunately there is no LIMIT option when performing a get query in flow. If your get query returns more than 50k results or your delete tries to delete more than 10k records, it will fail.

  • @lahcenlamkirich5174
    @lahcenlamkirich5174 ปีที่แล้ว

    Is there really a way to reset the org data l? ike what you did in 11:58 ... Thanks !

    • @DanielSoileau
      @DanielSoileau 10 หลายเดือนก่อน

      Except for the org's recycle bin, not exactly. That's why you always want to do thorough testing and keep backups as a last resort. This "reset" was really re-inserting sample test data using a couple of anonymous apex executions.

  • @ibbiesantaloci2683
    @ibbiesantaloci2683 ปีที่แล้ว

    ☹️ *PromoSM*