Scenario :- Write a code to implement following requirement.When Account is created, give access to the users who belong to a Queue to work on account and its related opportunity. Solution :- Here we will use the concept of accountteammember to provide account access to other users who are going to work on it. Apex… Continue reading Coding Scenario 18 — Account Team Members
Category: Coding scenario
Coding Scenario 17 — Quote and QLI
Question :- Write a code to implement following requirement. When an opportunity is created/updated with status as prospect then create a quote and auto assign product to the quote with predefined quantity. OpportunityTrigger :-trigger opportunityDemotrigger on Opportunity (before insert, after insert, after update) { if(trigger.isafter){ if(trigger.isinsert){ OpportunityTriggerHandlerUpdated.opportunityInserthandler(trigger.new, trigger.newmap); } if(trigger.isupdate){ OpportunityTriggerHandlerUpdated.opportunityUpsethandler(trigger.new, trigger.oldmap); } } if(trigger.isbefore){… Continue reading Coding Scenario 17 — Quote and QLI
Coding Scenario 15 || Lead conversion scenario
Implement a trigger to automatically convert a lead to an opportunity when status is changed to processed. trigger LeadTrigger on Lead (after update) { if(trigger.isafter){ if(trigger.isupdate){ List<database.leadconvert> leadsToconvert = new list<database.leadconvert>(); database.leadconvert lc; for(lead le : trigger.new){ if(le.status == 'Processed' && le.status != trigger.oldmap.get(le.id).status){ lc = new database.leadconvert(); lc.setleadId(le.id); lc.setDoNotCreateopportunity(false); lc.setOpportunityName(le.LastName+' '+le.LastName+' Opportunity'); lc.setConvertedStatus('Closed -… Continue reading Coding Scenario 15 || Lead conversion scenario
Coding scenario in salesforce – 8
Write a code to keep account and opportunity owner in-sync Scenarios When opportunity is created, set owner id as related account owner id. trigger opportunityDemotrigger on Opportunity (before insert) { if(trigger.isbefore){ if(trigger.isinsert){ set<id> relatedaccountIds = new set<id>(); for(opportunity opp : trigger.new){ relatedaccountIds.add(opp.accountId); } map<id,account> accMap = new map<id,account>([select id,ownerid from account where id IN :relatedaccountIds]);… Continue reading Coding scenario in salesforce – 8