You need to sign in to do that
Don't have an account?
sfdc03
Can someone tell me solution for this trigger?
Whenever existing Account is updated with AnnualReneue more than 10k and Industry as Technology then create a new opportunity for this account with same account name, stage name prospecting...
Use the below code for your requirement to create new opp when the account AnnualReneue is more than 10K.
also, you can achieve using the process builder to achieve the same functionality.
Thanks & Regards,
Sakthivel Madesh
Please try this code below to get expected results-
Trigger:
trigger AccountFieldToOpp on Account (after insert,after update) {
AccountTrigg.createOpp(trigger.new);
}
Trigger Handler:
public class AccountTrigg {
public static void createOpp(List<Account> acList)
{
List<Opportunity> opList =new List<Opportunity>();
for(Account ac: acList)
{
if(ac.AnnualRevenue > 10000 && ac.Industry=='Technology')
{
Opportunity op =new Opportunity();
op.Name =ac.name;
op.AccountId=ac.id;
op.StageName='Prospecting';
op.CloseDate= date.today();
opList.add(op);
}
}
insert opList;
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
Please try Below code
Thanks