function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jenny jadejenny jade 

How to convert an Opp from contact

Has anybody tired converting only an opportunity from Contact.
I know Lead conversion .
But as one of my projects .I need to have a button convert opp on Contact and that creates an opportunity alone.

Any solutions please
Andrew EchevarriaAndrew Echevarria
Can you do it through Apex? You can create a Apex method that is referenced by the button where you create a new Opportunity, get the fields from the Contact record, and insert it.

Otherwise, try process workflow builder!
Maharajan CMaharajan C
Hi Jenny,

Please Refer this link :

Can you please let me know if you want any further help?

brahmaji tammanabrahmaji tammana
Hi Jenny,

This can be acheived through AJAX Toolkit on button click. Here is my solution:

Create a new button (New Opportunity) and select Display Type as Detai page Button Behaviour: Execute javascript
and paste below code in JS editor:

var Opp = new sforce.SObject("Opportunity"); 

//Add all mandatory fields here
Opp.Name = prompt('Enter new Opportunity Name'); 
Opp.StageName = prompt('Enter Opportunity stage');
Opp.Discount_Percent__c = prompt('Enter Discount');

var result = sforce.connection.create([Opp]); 
alert('Opportunity Created successfully'); 
alert('Error : '+result); 
Basically we are collecting Opportunity data and creating a record through ajax request. If the transaction is success it will alert with a message else it will throw an error.

jenny jadejenny jade
Hi Brahma,

I pasted your code,but there are few required fields on my opportunity beacuse of which the button is failing.
Could you please guide me on how to pass all Opportunity required fields and few of them are picklist fields.It would be great if you can help me on this.
brahmaji tammanabrahmaji tammana
Hi Jenny,

As mentioned in my script comments, Add all the required fields with similar syntax. 
Opp.Name = prompt('Enter new Opportunity Name');

I believe you need to add all the required fields here manually. Please check below link to fetch picklist values in prompt window.

Hope it helps.