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
arti7arti7 

Is there anyway to pre-populate opportunity name value

Hello,

 

I would like to pre-populate opportunity name value after I clicked "New" button in the Opportunity Tab.

 

I know how to replace opportunity name after I clicked "Save" button in the entry page of Opportunity.

 

I just would like to know how to pre-set it before saving data.

 

Thank you in advance.

 

 

 

 

GoldwinGoldwin

you can acheive this by extending the controller. Make sure your VF page has the following apex::page tag

<apex:page standardController="ObjectA" extensions="ObjectAExtension">

</apex:page>

 

The controller class should be as below

 

public with sharing class ObjectAExtension

{

public ObjectA  oa {get; set;}

 

public ObjectAExtension(Apexpages.standardController sc)

{

oa = (ObjectA) sc.getRecord();

oa = [select field1, field2, ... from ObjectA where id = :oa.id];

                //Make changes to the fields that you want to pouplate by default

}

//This is for updating the record after user enters the values and submits to save

public Pagereference updateOA()

{

update oa;

}

}

 

 

In the VF page refer to the fields of ObjectA using apex:inputField tag to respect the datatype by default.

 

Ref:http://boards.developerforce.com/t5/General-Development/Populate-fields-in-VF-page-that-is-linked-from-a-custom-object/m-p/218037#M48266

Pradeep_NavatarPradeep_Navatar

You can't set a value in opportunity name after clicking on new button in opportunity object. For this create a standard controller with a extension to get record in constructor and select the field in which you want to set / update the values.

 

Hope this helps.