-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedback #1
base: feedback
Are you sure you want to change the base?
Feedback #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work!
newContacts.add(con); | ||
} | ||
insert newContacts; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really good! I typically hate seeing the curly braces with the logic on the same line as a predicate condition. But in this case, I think it made your mode much more readable. I like it.
Another thing you could explore is the use of the null coalescing operator to assign a default value if something evaluates to null
private void setDefaultBillingAddress(){
for(Account account : accounts){
account.BillingStreet = account.ShippingStreet ?? '';
account.BillingCity = account.ShippingCity ?? '';
account.BillingState = account.ShippingState ?? '';
account.BillingPostalCode = account.ShippingPostalCode ?? '';
account.BillingCountry = account.ShippingCountry ?? '';
}
}
```
@@ -0,0 +1,3 @@ | |||
trigger MyFirstTrigger on Opportunity (before insert, after insert) { | |||
System.debug('Hello World!'); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sure you left this behind by mistake but you never want multiple triggers on an object
for (Opportunity opp : Trigger.old) { | ||
if (opp.AccountId != null) { | ||
accIds.add(opp.AccountId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is good. A different approach would be to add the ids where the Opp = closed won. So you only query for those.
} | ||
} | ||
|
||
Map<Id, Account> accMap = new Map<Id, Account>([SELECT Id, Industry FROM Account WHERE Id IN :accIds]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would add a where clause and filter for Industry = Banking
for (Opportunity opp : Trigger.new) { | ||
if (opp.Amount < 5000) { | ||
opp.addError('Opportunity amount must be greater than 5000'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good. I would check less than or equal too. My assumption since the error message says that the amount must be greater than
|
||
for (Opportunity opp : Trigger.new) { | ||
Contact ceoCon = conIdMap.get(opp.AccountId); | ||
if (ceoCon != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this value could ever be null.
👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to
main
since the assignment started. Your teacher can see this too.Notes for teachers
Use this PR to leave feedback. Here are some tips:
main
since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.main
. Click a commit to see specific changes.For more information about this pull request, read “Leaving assignment feedback in GitHub”.
Subscribed: @arieltahimik