You need to sign in to do that
Don't have an account?

How do I create a new Opportunity with specific record types in Visualforce page ?
Hi All,
I want to develop a custom Opportunity Visualforce page to create a new Opportunity with Specific Record type.
// sample code
Opportunity opp = new Opportunity();
But the problem is above code is created a standard opportunity rather then specific record type Opportunity
I have also try this code
// Opportunity opp = new Opportunity(Recordtypeid=’0123000000001O6’);
Still Its not working…
Please let me know if anyone has any idea.
Thanks in advance
Deepak
I want to develop a custom Opportunity Visualforce page to create a new Opportunity with Specific Record type.
// sample code
Opportunity opp = new Opportunity();
But the problem is above code is created a standard opportunity rather then specific record type Opportunity
I have also try this code
// Opportunity opp = new Opportunity(Recordtypeid=’0123000000001O6’);
Still Its not working…
Please let me know if anyone has any idea.
Thanks in advance
Deepak
Opportunity opp = new Opportunity(Recordtypeid='0123000000001O6')
Works for me. Are you sure the running user of the VF page has a profile that allows the use of the record type you are setting?
Thanks for your quick response.
after your reply , i was try to access directly record type , but i got error saying that "Insufficient privilege" .
Kindly guide me how do i get this permissions or what are the setting that's needs to be modified for me as a user to this VF page.
Thanks once again.
Deepak
If you go to Setup, select Manage Users from the menu, then select the profile of the user you need to have access to the record type. You will see a section called record types, and for the Opportunity object, an edit link that will provide you a list of available and selected record types for that user profile. You should also look at the page layouts available for the user, and make sure they support the record type you are interested in.
I have checked all the settings that you have mentioed below but, i have all the rights like i see that campaign in my profile and page layout also. ie my profile support that record type.
I have sys-admin rights.
but still the problem is remain same , i am not able to get specific Record Type opportunity.
The basic problem is for "STAGE" field i have around 8 options that is for Standard Opportunity. But for that specific Record type Opportunity i have only 4 option.
while creating VF page with specific record type i still get 8 option for " STAGE " instead of 4 option.
i hope you get my points.
let me know your thoughts.
Thanks,
Deepak
Message Edited by Deepak Pansari on 12-28-2008 11:12 PM
One option you might consider would be to create the picklist (selectOption) yourself using the limited available responses, and supply that back to the object at creation time.
Hello Jim,
I am having the same issue as Deepak. I have a certain set of stages associated with each record type on opportunities. I have built a VF page for a quickview of your latest opportunities and as I added the column for the current stage, the drop-down gives you a list about a mile long with every stage associated with the opportunity object. Coul you shed some light on the selectObject and maybe a guideline for setting up my own picklist in the code?
Thanks for your support.
pschiffli@bokf.com
Basically, you have 2 options for select lists, you can either hard code the values to the list, or you could extract them from the system with a SOQL statement. Since you are trying to emulate a picklist, I would recommend hardcoding, since there likely would not be a good way to select values to match your dependent picklist filters.
You first create a SelectList element, then you create SelectOption items and place them in a selectOptions array.
Here is a code snippet that might help (right from the help, includes both the page code and the controller code):
Thank you for the guidance and options. I will look into the select Option array and see what I can make of it. It looks as though I have a few more hours of hard coding as I have 12 record types and about the same amount of options for each. Ha-ha! All in a weeks work, right?
Thanks again for your assistance. I will try this out and see what I can make happen.
Patrick
http://ideas.salesforce.com/article/show/10092833/Support_Dependent_Picklists_in_Visualforce#skin=adn
Link
Thanks Jim!
Hello again Jim,
Are those two code blocks supposed to be together in the same editor with the VF page apex code?
Forgive my ignorance, I am new to the development aspect.
Thanks again and have a happy new year!
Patrick
Jim, sorry I am such a knucklehead,
Does this source code look anything like it should for the selectOption function?:smileysad:
Basically when you click "New" on Opportunities, there are 16 different record types to choose from in the list, if you pick one, each has a filtered stage list of the "sales process" associated with that particular group. BBG is our Business Banking Group ie: Prospecting, Closed/Won, Closed/Lost, etc.
I am just not sure if I am approaching this in the most efficient manner.
You should also look at the documentation for the SelectOption functionality, in the salesforce_pages_developers_guide.
Each of the options you are creating (with the options.add method) is creating a new selectoption object. This needs to have value and a label.
The way you have it configured, no matter which option the user selected, the value would always get returned as "BBG". You would likely want to have it set up more like this:
So that when you go to create or update your Opportunity, you are setting the Stage with an appropriate value.
The limitation caused by no support for dependent picklists will likely cause you to have to write a lot of code to simulate the functionality.
You may need to create a map that contains all of the dependent lists, by record type, and then dynamically generates the stagelist based on the recordtype selected. Honestly, I have been working on this issue for a while, and we have not implemented a VF version of our Opportunity page because of this issue. I am hopeful that the functionality is supported before I absolutly need to have a custom page.
Jim,
I definitely appreciate your feedback. That was the general thought on my end as well. The custom page I created gives the entire list, but for now, that might have to suffice. I have gotten several others on the dependant picklist bandwagon and had them vote on this functionality as well, so hopefully there is some strength in numbers there.
Thank you for your quick responses. That is the best feedback I have received since joining in on the community fun. I really appreciate it once again.
I look forward to speaking with you soon!
Have a Happy New Year!
pschiffli@bokf.com
It’s me again,
Can we says that "Stage" filed is a dependent pick list or is there any other definition of dependent pick list ( In My Case ).
My case: I am getting all possible option values for field “Stage “in Opportunity, even after creating for specific Record type.
Thanks
Deepak
The only thing you can do is create custom selectlists for your stagefield on the VF page, and populate it based on the recordtype selected.
All manual, unfortunately.
Jim,
You will let me know when this feature becomes a reality in VF, right? Ha-ha!
I am trying to stall this project until it becomes supported for sake of time and money spent on coding.
Have a good one!
Good Luck!
It’s me again,
I am able to create “Stage” pick-list manually, but still I wanted to do it from standard way.
We can customize the Options of Stage pick-list by "Sales Process".
Opportunity Sales Process - found in: Setup -> Customize -> Opportunities -> Sales Processes,
Can any one have any idea, how we can call Sales Process while creating Opportunity in Visualforce page.
Thanks
Deepak
You could create a map of the stage values for each Sales Process (Business Process), then generate the list from the Map, based on the Business Process ID of the Record type. It would still be very much manual, and I don't think it would really provide any value over a completely manual method.