Want to see how your learning is coming along? Give these challenges a shot!
# | Challenge | Difficulty | Recommended Reading |
1 | Lazy Employee | Beginner | Chapter 1 |
2 | Account Rivals | Advanced | Chapter 5 |
3 | Opportunity Renewal | Intermediate | Chapter 6 |
4 | Extravagant Record Creation | Advanced | Chapter 7 |
5 | Custom Sales Territory Management | Advanced | Everything! |
If you have any hesitation within you, I recommend a nice cold beer (or two). Always works for me!
Not having too much difficulty solving these challenges? Start applying for Salesforce developer jobs!
…and once you get the job, find me and tell me your story!
David
challenege to be solved in apex
can anyone solve this problem
Create a master list of facility having the conference room with facilities available for different locations of an office.
Request for a meeting room by selecting meeting room, meeting time slot, date/time.
Compare the above mentioned values and status as “Room booked” or “Meeting Room Not Available for Booking/Slot rejected” on display.
Option should be available for Reservation against cancellation.
Hi David,
Can you post some more challenge questions or provide a source for the same?
Like some scenarios for apex coding practices as well as apex trigger practices.
Check out bit.ly/go-apex
// Automatically create a Renewal Opp for closed won deals
trigger CreateRenewal on Opportunity (before update) {
// Create a Map to store all renewal opps for bulk inserting
List renewals = new List();
Opportunity renewal;
Opportunity oldOpp;
//Get Renewal Record Type ID
Id RenewalRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get(‘Renewal’).getRecordTypeId();
for (Opportunity opp : Trigger.new) {
//Check if the current opportunity was not ‘closed won’
oldOpp = Trigger.oldMap.get(opp.Id);
Boolean oldOppIsWon = oldOpp.StageName.equals(‘Closed Won’);
// Only create renewal opps for closed won deals and were previously not ‘closed won’
if (opp.StageName == ‘Closed Won’ && !oldOppIsWon) {
renewal = new Opportunity();
renewal.AccountId = opp.AccountId;
renewal.Name = opp.Name + ‘(Renewal)’;
renewal.CloseDate = opp.CloseDate + 365;//add a year
renewal.StageName = ‘Open’;
renewal.RecordTypeId = RenewalRecordTypeId;
renewal.OwnerId = opp.OwnerId;
//Add Opportunity to list
renewals.add(renewal);
}
}
// Bulk insert all renewals to avoid Governor Limits
insert renewals;
}
trigger caseLimit on Case (before insert,before update,after undelete) {
map<Id,list> ownerIdtocases = new map<Id,list>();
set ownerIdSet = new set();
for(case c:trigger.new){
ownerIdSet.add(c.OwnerId);
if(ownerIdtocases.containsKey(c.OwnerId)){
ownerIdtocases.get(c.OwnerId).add(c);
}
else{
ownerIdtocases.put(c.OwnerId,new list{c});
}
}
for(case c:[SELECT ownerId,CreatedDate
FROM case
WHERE createdDate = THIS_MONTH
AND OwnerId IN:ownerIdSet]){
if(ownerIdtocases.containsKey(c.OwnerId)){
ownerIdtocases.get(c.OwnerId).add(c);
}
else{
ownerIdtocases.put(c.OwnerId,new list{c});
}
}
ownerIdSet.clear();
for(list c:ownerIdtocases.values()){
if(c.size()>99)
ownerIdSet.add(c.get(0).OwnerId);
}
for(case c:trigger.new){
if(ownerIdSet.contains(c.OwnerId)){
c.addError(‘Too many cases created this month for user’+ c.OwnerId);
}
}
}
wonder
This is just a request that wouldn’t it be great if you keep coming with few (2 to 3 only) trigger questions/Challenges per week and just post the question here on sfdc99? It will help us to brush up our all skills that we have learned in 3 courses so far.
Thank you sir & I appreciate your time reading comments here, Thank You!
That is a FANTASTIC idea!
Thanks for replay..
And Of course, the difficulty level can increase as we move further in challenges!
I am looking forward then David!
now it’s like…. can’t go to sleep if I don”t write some lines of code :) I am not kidding;)
Great attitude!!
So David when do we expect to see you putting some extra challenges for us to work on and brush up our skills we learned so far? Thank you for your time, as always!
LOL it’s on the backlog!! It’s a BIG backlog!
Hi David
I have referred your org and came to know about iframe to be used to display youtube video in VF page. When I tried to demonstrate this with other video link (apart from what you have coded) , I found its failing. In analysis I could understand its because of the parameter it is receiving in the link.
Now my question is that if someone wish to use youtube link mentioned like below in the code , how it should be done.
https://www.youtube.com/watch?v=Vov2OsA1JII
Thanks in advance for kind help.
Regards
Sandeep
Check this out:
https://www.sfdc99.com/2015/02/20/example-how-to-write-a-basic-visualforce-page/
Hi David
I got the answer , it was my mistake , we should use embed link rather than the direct link what we come across in youtube.
I did the changes and worked fine.
Thanks .. thought to share .. may be useful for someone who will come across such scenario in future. :-)
Thanks
Sandeep
The visual page force should contain 6 fields of Custom Object.
We should be able to enter values in those fields and those values when clicked on the Save button should save in the custom objects.
pls send code.
thanks in advance
The visual page force should contain some fields of Custom Object.
We should be able to enter values in those fields and those values when clicked on the Save button should save in the custom objects.
Waiting on the next chapters:-) Champion gets slow:-)
=)
Hi David and experts,
I have a situation, I want to mass update a custom object’s custom fields. I’m using list, but somehow its only updating first and last record. Please let me know, if I’m doing something wrong. Here is the code
Account[] AcctFin = [select Id, (select Id,IsLatest__c from Account_Financials__r
order by date__c desc limit 1) from Account where Number_of_Financials__c > 0 limit 5];
list lstFin = new list();
for (Account A : AcctFin){
for(Financials__c fin: A.Account_Financials__r){
lstFin.add(fin);
}
}
for(Financials__c F : lstFin){
if(F.IsLatest__c != true){
F.IsLatest__c = true;
}
}
update lstFin;
Try posting this one on the forums!
Hi David
I have a requirement where user can enter account details thru which he/she will receive the payment(confidential information like account details), but no one in the org can able to see that field …and that field should in in encrypted formate.
Please advise
Try using an encrypted field and setting sharing to private (without granting access using hierarchies)
Hi David,
we have used Standard set Controller for getting list views & for pagination from this link: http://www.jitendrazaa.com/blog/salesforce/listview-filter-in-apex-with-paging-and-navigation/ .
Now we need to change the pagination to somwthign like this :http://demo.redpointsolutions.com/Dynamic_Visualforce_with_SOQL_Offset
Could you please suggest some possible chances to acieve this.
Thanks,
Koti
It’s very close!
You just need to code the buttons to say the current page numbers instead of the arrows. This is one more thing to track in your controller.
Also, you need to add a few more buttons but that shouldn’t be too difficult!
David –
Big fan here.
Are you going to post the solutions to the other Trigger problem??
Almost forgot about that! Yes they will come! Next post will be on Chapter 8 first though!