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
nbknbk 

How to render dynamic fields in Fieldset

Hello Everyone,

 

I have a requirement to render dynamic fields in Field set  by Location wise.

More Details:

1) Fieldset structure

 

Fieldset Name       Available fields    Object Name

General                    Account Name     Account

                                   Employees

                                   Year established

                                   Location

 

2) If the Account location is "Australia" need to render the following fields. not required to show (Year & Location) fields

Fieldset Name       Available fields    Object Name

General                    Account Name     Account

                                   Employees

                                   Year established

                                   Location

 

3) If the Account location is "Australia" need to render the following fields. not required to show (Year ) fields

Fieldset Name       Available fields    Object Name

General                    Account Name     Account

                                   Employees

                                   Year established

                                  

Can  you post your ideas/solutions how to acheive the requirement without creating new fieldset.

Expectation: One field set is ability to handle the fields dynamically by Location .

 

 

 

 

 

Avidev9Avidev9

Well lets take the case 2 of yours.

 

The code should be something like 

<apex:repeat value="{!$ObjectType.Account.FieldSets.AccountFieldSet}" var="f">
  <apex:outputField value="{!myAccount[f]}" rendered = "{!IF(AccountObj.location == 'Australia' && (f == 'Year_established__c' || f == 'Location'),true,false)}"/>
</apex:repeat>

 I guess you can modify the above code to suit your requirements

nbknbk

Thanks Avi for Reply.

 

The solution is good if we use limited fields, but I have more fields in fieldset assume that 10 to 15 and it requires to include all possible fields in rendered attribute. I hope it is difficult to satisfy the criteria and need to implement same mechansim for multiple fieldsets(around 20 fieldsets)

 

Can you let me know if there is any feasible solution to acheive the requirement.

 

Thanks,

Krishna

 

<apex:outputField value="{!myAccount[f]}" rendered = "{!IF(AccountObj.location == 'Australia' && (f == 'Year_established__c' || f == 'Location'),true,false)}"/>


Avidev9Avidev9

You have to make the system understand what you want to do, be it apex or visualforce. To limit the number of fields just negate the Condition.

 

<apex:outputField value="{!myAccount[f]}" rendered = "{!IF(AccountObj.location == 'Australia' && (f != 'Somefield__c' && f != 'OtheField__c'),true,false)}"/>