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
mrhmrh 

OutputText field 'rendered' attribute options

Hello

 

I have an input screen which contains a group which consists of a single repeated field, i.e. to allow a user to enter up to 5 different account names (all of the same defined field).

 

When displaying this information on the 'View' page, I have the following code which also suppresses any of the repeated fields that have not been completed (i.e. are blank) by the user from being displayed.  So if the user only enters 3 account names, only 3 fields are displayed.

 

<apex:repeat value="{!RepeatingGroup5}" var="group5">
    <apex:outputField id="accountName" value="{!group5.Account_Name__c}"/>
    <apex:outputText rendered="{!ISBLANK(group5.Id)}" value=" "/>
</apex:repeat>

 

What I would like to do is add to the 'rendered' attribute on the output text to also suppress not only blank fields, but any that contain the default value for this account name field.

 

So if all of these account name fields have a default value of 'X     1' on the input page, and a user only fills in 3 account names, leaving 2 fields with the value 'X     1', these are not displayed on the view page.

 

Is this possible in the above code and would anyone be able to explain how to do this?

 

Many thanks in advance

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

This will render a blank string if the field is blank or the default value.  It won't suppress anything - you'd need a rendered attribute on the output of the name too.  Do you have that.

All Answers

bob_buzzardbob_buzzard

You should just be able to add an OR condition to the rendered attribute.

 

Something like:

 

<apex:outputText rendered="{!OR(ISBLANK(group5.Id), group5.Account_Name__c=='X   1')}" value=" "/>

 

mrhmrh

Thanks Bob

 

I gave that a try, here is the actual line I inserted with real values:

 

<apex:outputText rendered="{!OR(ISBLANK(newFormChild5.Id), TRIM(newFormChild5.License_Number__c) == 'X    01')}" value=" "/>


however it is still only just excluding blank license numbers from the display.  The fields with a default value are still being displayed  Is there any more information I can provide to help further?

 

Many thanks.

Mark

bob_buzzardbob_buzzard

This will render a blank string if the field is blank or the default value.  It won't suppress anything - you'd need a rendered attribute on the output of the name too.  Do you have that.

This was selected as the best answer
mrhmrh

Thanks again Bob.

 

I just added this and it all works correctly now.  Putting the rendered option on the outputField ensures the default value fields are ignored.

 

<apex:outputField id="LicenseNo" value="{!newFormChild5.License_Number__c}" rendered="{!TRIM(newFormChild5.License_Number__c) != 'X    01'}"/>

 

Best Regards,

Mark