• Ricardo Manaia
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi everyone,

So this is my first attempt at writing an Apex trigger and it seems to be working fine in the Sandbox.
I've now got a couple of questions that I'm hoping you could help me with:

1. You can see the trigger is simple enough, just a bunch of IF statements but it does the job. As I'm only starting in this area I'm unsure if I took the right approach and if it even complies with best practices used with Apex triggers.
Could or should I have used FOR loops instead? Would any code variations be more suitable?
Are there any risks of falling in an endless loop?

2. How do I go about creating Test Classes for this trigger?

Any help with the above is welcome! Thanks a million guys!

Code snippet
Hi everyone,

So this is my first attempt at writing an Apex trigger and it seems to be working fine in the Sandbox.
I've now got a couple of questions that I'm hoping you could help me with:

1. You can see the trigger is simple enough, just a bunch of IF statements but it does the job. As I'm only starting in this area I'm unsure if I took the right approach and if it even complies with best practices used with Apex triggers.
Could or should I have used FOR loops instead? Would any code variations be more suitable?
Are there any risks of falling in an endless loop?

2. How do I go about creating Test Classes for this trigger?

Any help with the above is welcome! Thanks a million guys!

Code snippet