+ Start a Discussion
Lavanya Ponniah 3Lavanya Ponniah 3 

how to copy the one object choosen picklist value to other object Picklist fields in the VF page

Boris BachovskiBoris Bachovski
It'd be good if you provide a bit of background around your qestion and maybe some code snippet of what you've done so far. Here is a basic example:

public class MyClass
	public Object1__c object1record {get; private set;}

	public void init()
		object1record = [SELECT Id, PicklistField__c FROM Object1__c WHERE Id = 'object1ID'];

	public void save()
		Object2__c object2record = new Object2__c();
		// Make sure the picklist values for this field on both objects match
		object2record.PicklistField__c = object1record.PicklistField__c;
		insert object2record;

<apex:page controller="MyController" action="{!init}">
	<!-- some code -->
	<apex:inputField value="{!object1record.PicklistField__c}" />
	<!-- some code -->
	<apex:commandButton value="Save" action="{!save}" />

praveen murugesanpraveen murugesan
Hi Lav,

If I understood correctly,

You need to use onchange function in vf page and u need to use apex:param to pass the value to controller.

From the controller you can assign this to other picklist field in other obj.

Mark it as best answer if its helps.


Praveen Murugesan
Lavanya Ponniah 3Lavanya Ponniah 3
Hi Praveen,

Can u pls give sample code for that.