-
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
opp.stageName = 'Qualification'; // Set the Opportunity's Stage to Qualification | ||
opp.closeDate = Date.today().addMonths(3); // Set the Opportunity's Close Date to 3 months from today | ||
opp.amount = 50000; // Set the Opportunity's Amount to 50000 | ||
System.debug(LoggingLevel.FINEST, 'Opportunity Name' + opp.Name); |
Check warning
Code scanning / PMD
Debug statements contribute to longer transactions and consume Apex CPU time even when debug logs are not being captured. When possible make use of other debugging techniques such as the Apex Replay Debugger and Checkpoints that could cover *most* use cases. For other valid use cases that the statement is in fact valid make use of the `@SuppressWarnings` annotation or the `//NOPMD` comment. Warning
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.
Try to take debugs out of the final submission if they are not needed anymore.
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.
Hi Jené,
I see that you put a lot of hard work on this and it shows. Great Job!!
I just added a few things to try when you get a chance.
// Set the AccountId field to the given accountId | ||
|
||
// Insert the Contact into the database | ||
|
||
insert contact; |
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.
Try to see if the user has permission to insert a contact
https://salesforce.stackexchange.com/questions/92209/how-to-check-access-of-user-for-particular-user-on-object
// Upsert the opportunities List so that records are either updated or created | ||
upsert opportunities; |
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.
For the future, if you ever run into an error because you're updating the same list that you are iterating over, you'll need to create a new list and add to that list.
insert matchedAccount; | ||
} else { | ||
matchedAccount = accountToInsert[0]; //Use the first record | ||
} | ||
|
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.
Try to move the insert matchedAccount to line 181 and change it to an upsert
for (String opp : oppNames) { | ||
//add to listToBeUpserted only if opp name is not already in the existingOppsList | ||
if(!existingOppsNames.contains(opp)) { | ||
Opportunity oppsToAdd = new Opportunity( | ||
Name = opp, | ||
StageName = 'Prospecting', | ||
Amount = 70000, | ||
CloseDate = date.today().addMonths(2), | ||
AccountId = matchedAccount.Id | ||
); | ||
// Add the Opportunity to the list | ||
listOfOppsToBeUpserted.add(oppsToAdd); | ||
} |
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.
Awesome! glad you were able to get through this one.
} | ||
accounts.add(newAcc); | ||
// Upsert the Account | ||
upsert newAcc; |
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.
Try using a try and catch block to catch errors and handle them
List<Lead> listOfLeads = new List<Lead>(); | ||
|
||
// Loop through each Lead name | ||
for (String l : leadNames){ |
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.
Try to avoid using single letters as variables, make them a little descriptive if you can
storeCase.add(caseToAdd); | ||
caseToAdd.AccountId = 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.
Try to reverse these two lines. Assign the AccountId before you add it to the list. Your way probably works too, just not accustomed to seeing it reversed.
👋! 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 the default branch since the assignment started. Your teacher can see this too.
Notes for teachers
Use this PR to leave feedback. Here are some tips:
For more information about this pull request, read “Leaving assignment feedback in GitHub”.
Subscribed: @salesforcejene