So here is my requirement :-
I want to populate opportunity Name same as Account Name on my visual force opportunity Page.
what i have done so far :- I have written a class
public class testopportunity {
public Opportunity c;
public Account acc ;
public testopportunity(ApexPages.StandardController ctrl){
c = (Opportunity) ctrl.getRecord();
}
public void fetchRelatedAccountData(){
if(c.AccountID!= null){
acc = [SELECT Name
FROM Account WHERE Id = :c.AccountID];
c.Name = acc.Name;
}
}
}
Visual force code i have used is
<apex:PageBlockSectionItem >
<apex:outputLabel value="Product"/>
<apex:actionRegion >
<apex:inputField value="{!Opportunity.Product_picklist__c}" >
<apex:actionSupport event="onchange" reRender="ajaxrequest" />
</apex:inputField>
But strange thing happening is the VF page says first fill all the mandatory field and my bad luck is all the field are mandatory.
Can we achieve this requirement by java script. Or i have to modify my code?
Kindly help!