You need to sign in to do that
Don't have an account?
Forrest Muldune 36
opportunity record type
I have created the trigger below
trigger Opportunity_CS_Default_Stage on Opportunity (before insert) {
for(Opportunity opp: trigger.new){
opp.stagename = 'Identification';
}
}
How can I update this trigger so that it will only updated the stagename = 'Identification' , and when the Opportunity Record type name = Concept_Team only ?
trigger Opportunity_CS_Default_Stage on Opportunity (before insert) {
for(Opportunity opp: trigger.new){
opp.stagename = 'Identification';
}
}
How can I update this trigger so that it will only updated the stagename = 'Identification' , and when the Opportunity Record type name = Concept_Team only ?
Note : Id recIdConceptTeam = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Concept_Team').getRecordTypeId();
in above statement use developer name of record type here( bold text above) :
if it helps you, closed your query with choosing best answer so it make proper solution for others in future
Thanks
I appreciate your trigger, however when I created a new opportunity using the Concept_Team record type, the value "Identification" did not populate in the stagename field. I know the Sobject Type is Opportunity as well.
do you know what could be the issue?
Trigger is active
The Record Type developer name is actually Concept_Systems , I updated this part of the code get('Concept_Systems') but it still did not work.
in the Concept System sales process, Identification value is located in the "Available Values" View. I moved it to the "Selected Values" view and it still did not work.
I have permission to this record type
View code below after I updated the record type name.
trigger Opportunity_CS_Default_Stage on Opportunity (before insert) {
for(Opportunity opp: trigger.new){
Id recIdConceptSystems = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Concept_Systems').getRecordTypeId();
system.debug(recIdConceptSystems);
if(recIdConceptSystems == opp.recordTypeId){
opp.stagename = 'Identification';
}
}
}
Do you know what could be the issue?
After selecting the "new" button on an Opportunity where Concept_System is the record type, the Identification value is not displayed in the opportunity stage before I save it.
Go to the record type and see the values of picklist and make "Identification" as default.
The purpose of trigger is not to auto populate values before SAVE. URL hacking would do that.
I appreciate your feedback. the Field I am trying to set the default value is on the Opportunity Stage. This field is not located on the Record Type but It is located in the standard field and I was unable to set a default value there.
I found this website on Ideas https://success.salesforce.com/ideaView?id=08730000000BrKdAAK and I read the comment below
"Workaround doesn't work for Opportunity Stage since it is a required field, why is it so hard to make a new Opportunity default to a stage that it almost always starts in?"
will URL hacking solve this issue? if yes, could you send me some helpful URL hacking solution?