You need to sign in to do that
Don't have an account?
sujatha dhanekula
Hi, I am not a developer. I need to write trigger on opportunity object, opp name should be auto populate accountname:oppname entered by user
Hi, I am not a developer. I need to write trigger on opportunity object, opp name should be auto populate accountname:oppname entered by user.
requirement is
company has decided to have the Opportunity naming convention as “<Account Name>: <Opportunity Name>”. For example, if the opportunity is pertaining to 200 laptops, from Account ABC, the Opportunity naming convention should be “ABC: 200 laptops”. However, do not mandate this to be filled in as such by users. Instead, automatically update the Opportunity name as <Account Name>: <Opportunity Name> if someone creates the Opportunity without Account Name already in it.
requirement is
company has decided to have the Opportunity naming convention as “<Account Name>: <Opportunity Name>”. For example, if the opportunity is pertaining to 200 laptops, from Account ABC, the Opportunity naming convention should be “ABC: 200 laptops”. However, do not mandate this to be filled in as such by users. Instead, automatically update the Opportunity name as <Account Name>: <Opportunity Name> if someone creates the Opportunity without Account Name already in it.
I don't think you need a trigger for that. You can do it with worflow itself.
Workflow Rule:
Workflow Field Update:
Thanks,
Sowmya.
1. Opportunity Account Name Should not be null (Should take Account Name NOT null).
2. No need of taking Opportunity Name condition as it is a mandatory field.
3. Make sure that you activated your workflow rule.
Thanks,
Sowmya.
You want to shorten the Account Name?
If it is your requirement, How much exactly you need your Account Name length should be?
Thanks,
Sowmya.
Please find the below code as per your requirement :
trigger OppNameTrigger on Opportunity (before insert) {
List<Account> acList =[select id,name from Account];
for(Opportunity op: Trigger.new){
for(Account acc:acList){
if(acc.id==op.Accountid){
op.name=acc.name+' '+op.name;
}
}
}
}
Thanks
Salesforce Developer Group
trigger OpNameApend on Opportunity (before insert) {
List<Account> acc =[select id,name from Account];
string name;
for(Opportunity op: Trigger.new){
for(Account a:acList){
if(a.id==op.Accountid){
if(acc.name.size()<=10){
name=a.Name;
}
else{
name=a.name.substring(0,10);
}
op.name=name+' '+op.name;
}
}
}
}
Replace your formula in Workflow FieldUpdate with the below formula,
LEFT(Account.Name, 10) +' : '+ Name
You have mentioned only one scenario before, let me know the requirement in details.
Thanks
Salesforce Developer Group
What if there are multiple products (ex: Mobiles & Laptops) for an opportunity? Should it be 200 Laptops 100 Mobiles Account Name?
Thanks,
Sowmya
That feature is there in Classic also. If you convert any lead a new opportunity is created with the Account Name.
But What exactly you need? You want to auto populate your Opportunity Name with Account Name + Opportunity Name or you want something else to be populated there?
Thanks,
Sowmya
For Single Workflow rule you can create multiple workflow Actions.
Thanks,
Sowmya
The answer was given in my first reply itself. Please refer.
You can create a new workflow for lead.
If your requirement is the same you can do it with workfllow itself.
Please replace your workflow rule with the below code
AND(Account.Name!= Null, NOT(CONTAINS( Name ,LEFT(Account.Name, 10) +' : ')) )
and your workflow field update with this:
LEFT(Account.Name, 10) +' : '+ Name
Mark it as a best answer if it satisfies your requirement.
Thanks,
Sowmya.
clock the drop down you will see formula editor.
Try thi in formula evaluates to true:
AND(Account.Name!= Null, NOT(CONTAINS( Name ,LEFT(Account.Name, 10) +' : ')) )
Thanks,
Sowmya.
Modify your Rule criteria as:
And FieldUpdate with the below formula:
IF(AND(NOT( ISCHANGED( AccountId ) ) ,NOT(CONTAINS( Name ,Account.Name +' : ')) ),Account.Name &' : '& Name,IF(AND( ISCHANGED(AccountId) ,NOT(CONTAINS( Name ,Account.Name +' : ')) ),Account.Name+' : '+SUBSTITUTE(Name, LEFT(Name, FIND(":", Name)), ''),Name))
I have checked it and it is working fine.
Thanks,
Sowmya.
Is it working fine?
Thanks,
Sowmya.
Set opportunity name criteria
AND( NOT(ISBLANK( Account.Name )), NOT( CONTAINS( Name , Account.Name +':')) ) not working when I convert consumer leads.
create opportunity
enter opportunity name = 200PC
select existiing account name = lendlease etc company name
submit opporuntiy name is updated to lendlease:200PC
but if you enterexisitn account name = person name (Uma ABB)
then submit opportunityname i still 200PC
any soulution please.