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

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

Generate CSV file in Apex

In this blog we will see how you can generate csv file in apex and send it as attachment in email. public with sharing class CSVGenerator { public void createCSVandemail(string accountIdVal){ list<opportunity> oppList = new list<opportunity>(); oppList = [select id,name,StageName,account.owner.email from opportunity where accountId=:accountIdVal]; string csvString = 'Opportunity Id,Opportunity Name,Opportunity Stage\n'; for(opportunity opp : oppList){… Continue reading Generate CSV file in Apex