Professional Documents
Culture Documents
If(trigger.isinsert || trigger.isupdate)
L1.add(acc.id);
List<Account> l2 =[select Name, (Select Name CloseDate, StageName from opportunities) from Account where ID
IN: L1];
For(Account acc2:acclist
If(acc1.id==acc2.id
{if(acc1.opportunities.size() < 1)
Insert opp;
}
}
2.
When an opportunity is inserted check for its duplicity on the basis of its
name and the account to which it is related to i.e. If it has same name and it’s
linked to same Account then append “Duplicate Opportunity” in the name.
List<opportunity> l1 = trigger.new;
ListID.add(acc.id);
ListID.add(acc.ID);
if(acc1.id==acc2.id)
If(acc1.opportunities.size()>0)
For(Opportunity opp:acc1.opprtunities)
If(Opp.stageName!=’Closed Won’)
5. Insert Account and opportunities data through CSV (Min 200 records).
Whenever any opportunity gets inserted we have to check that if the amount
is greater than 10000$ or not, if yes, then update the related account record
by setting “Rating” as Hot and “Customer Priority” as High.
Note: First import the Account records and then import opportunities relating
it with accounts. It is mandatory to relate each opportunity to an account.
Trigger insertOpportunityTrigger on opportunity(after insert)
List ID.add(opp.AccountID);
List<Account> acc =
For(Opportunity opp:newopp)
listID.add(opp.AccountID);
List<Account> acc =[Select Name, Rating, CustomerPriority__c(select Name, StageName, Amount, CloseDate
from Opportunities) from Account where ID IN:listID];
Acc1.Rating = ‘Hot’;
Acc1.CustomerPriority__c=’High’;
Update acc1;
Integer i=0
For(opportunity newopp:newlist)
For(opportunity list:oldlist)
I=i+1;
6. Whenever a lead gets saved with the source as “Phone Inquiry” then
automatically convert
it.
For(leadl1:leadlist)
L1.status=’Closed – Converted’;
If (i>=2)
Newopp.adderror(‘New opportunity cannot be created as there are already two open opportunities pending’);