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
gopathi parthiban Ramarajgopathi parthiban Ramaraj 

how to prepopulate picklist values via apex call when New opportunity record creation.

Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.

Visualforce:
<apex:page standardController="Opportunity" extensions="RedirectNewOpptyController" action="{!NavigateToURL}">
</apex:page>

Controller:
public class RedirectNewOpptyController {
    public RedirectNewOpptyController(ApexPages.StandardController controller) {
    }
    
    public pagereference navigateToURL(){
        return new pageReference('/006/e?retURL=%2F006%2Fo&ent=Opportunity&opp11=Prospecting');
    }
}

Override the standard 'New Button' with a visualforce page.


Also, please refer to below link which might help you further.

http://sfdcsrini.blogspot.com/2014/01/custom-button-to-pre-populate-field.html

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
gopathi parthiban Ramarajgopathi parthiban Ramaraj
Thanks for the reply Khan,
Am using lightning environemnt, i dont have experience on VF.
As part of my requirement, when i click on the New button on opportunity page to create new opportunity,
i added one custom picklist field that needs to be pre-populated from the source of remote call. Please suggest on this.
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

I suggest you please refer to below links:

https://salesforce.stackexchange.com/questions/116697/create-record-in-lightning-with-populated-fields

https://salesforce.stackexchange.com/questions/98983/pre-populating-fields-at-record-creation-in-lightning-experience

I hope it helps you.

Kindly mark this as solved if the information was helpful. It will help to keep this community clean.

Regards,
Khan Anas