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
Kalai ArumugamKalai Arumugam 

How to use two custom object's fieldsets in a single vf page?

I want to add two fieldssets from different custom objects in a single vf page. I tried using custom contoller with wrapper class, but I could not able to refer the object's fieldsets. Pls share your inputs.
Antonio ManenteAntonio Manente
You could get them using the Schema...
        Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe();
        Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(YOUR OBJECT NAME HERE);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
        Map<String, Schema.FieldSet> fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap();
        for(Schema.FieldSet f : fieldSetObj.values()){
            for(Schema.FieldSetMember m : f.getFields()){
                 //DESIRED BEHAVIOR HERE
            }
        }
You could duplicate this for your two custom objects (substitute 'YOUR OBJECT NAME HERE' with the desired custom object name), and do what you wish with the returned fields (where 'DESIRED BAHVIOR HERE' is located)
Kalai ArumugamKalai Arumugam
If I use the above method, how could I use the repeat functionlity in my vf page. I'm using the fieldset like below.
<apex:page controller="CustomContlrCheck">  

     <apex:pageblocksection title="Dispatch Details" columns="2">   
		<apex:repeat value="{!$CustomContlrCheck.Dispatch_Deatil__c.FieldSets.FE_and_Parts_FieldSet}" var="f">
			<apex:inputField value="{!Dispatch_Deatil__c[f]}" required="{!OR(f.required, f.dbrequired)}"/>
		</apex:repeat>
	</apex:pageblocksection>    

</apex:page>

 
Antonio ManenteAntonio Manente
One solution I can think of is in your controller when you iterate over the fields( line 7 of my above code sample ) you could add them to a list and substitute that list in the apex repeat value of your code sample and it should work.