You need to sign in to do that
Don't have an account?
Arpit Gupta 62
when a Account field Type is updated , then update Description from its related Opportunity i.e created date is oldest & if Description is not blank .
update Acc Description from its oldest Opty's Description
when a Account field Type is updated , then update Description from its related Opportunity i.e created date is oldest & if Description is not blank . update Acc Description from its oldest Opty's Description
when a Account field Type is updated , then update Description from its related Opportunity i.e created date is oldest & if Description is not blank .
update Acc Description from its oldest Opty's Description
Please find the following code.
rigger AccountFieldTypeUpdate on Account (before Update)
{
set<ID> account_Id=new set<ID>();
List<Opportunity> opps = new List<Opportunity>();
for (Account MyAccount : trigger.new)
{
if (MyAccount.Type != trigger.oldMap.get(MyAccount.Id).type)
{
account_Id.add(MyAccount.Id);
}
}
if(account_Id.size()>0)
{
list<Opportunity> Opportunity_list=new list<Opportunity>([ select id, Description from Opportunity where AccountId IN:account_Id order by CreatedDate DESC limit 1]);
for (Account MyAccount1 : trigger.new)
{
for(Opportunity opp1 : Opportunity_list)
{
if(opp1.Description != null)
{
MyAccount1.Description = opp1.Description;
}
}
}
}
}
Note: The above code will not work on bulk updates.