+ Start a Discussion
ckellieckellie 

Displaying fields when cooresponding multi picklist values are selected

 have a business case where I need to display the corresponding input field when a value has been selected. For example: when Phone and fax fields have been selected as to what needs to be added, the cooresponding Phone and fax fields will be displayed. Currently my code is:

 

<apex:actionRegion > <apex:pageblockSection columns="1" > <apex:pageBlockSectionItem > <apex:outputLabel value="What Information needs to be Corrected?" id="thePageBlock1"/> <apex:outputPanel > <apex:inputfield value="{!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c}"> <apex:actionSupport event="onclick" rerender="thePageBlock1" status="status1"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status1"/> </apex:outputPanel> </apex:pageBlockSectionItem><apex:pageBlockSectionItem > <apex:outputLabel value="Correct the Information"/> <apex:outputPanel > <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Correct_the_Information__c}"> <apex:actionSupport event="onclick" rerender="thePageBlock" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageblockSection> </apex:actionRegion> <apex:pageBlockSection columns="1" rendered="{!Manufacturing_Design_Sheet__c.Correct_the_Information__c==true}"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}" /> </apex:pageBlockSection> <apex:pageBlockSection columns="1" rendered="{!And(Manufacturing_Design_Sheet__c.Correct_the_Information__c==true, Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c=='Commercial Phone') }"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Phone__c}" /> </apex:pageBlockSection>

 

 

Any suggestions? I am needing to do the following:

1. Display alll fields connected to their picklist values

2. Specify which column each field is displayed.

Best Answer chosen by Admin (Salesforce Developers) 
ThomasTTThomasTT

> How do I check it?

System log and System.debug()... it's much easier than posting a question here... we don't debug with just watching a source code...we try something, analyze the log, and check the source code. Nobody else can run your source code now. You are the only one who can try with working code and see the log...

 

> I am not including Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c because...

I still don't understand why you intentionally used the actionRegion and didn't include  Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c field in it.

 

actionRegion is to limit fields/areas to process. "Process" means getting values from screen and sending them to server. If you don't include a field, it's not stored in the variable in the controller.

 

Another way to make SFDC process a field is to re-render. Add the field into reRender attribute of actionSupport, so that the value will be "processed" and the rendered attribute can examine the latest value of  Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c.

 

ThomasTT

All Answers

bob_buzzardbob_buzzard
Can you tell us what behaviour you are experiencing and how you would like it to change?  At the moment we just see your code but don't know what the problem is.
ckellieckellie

Here is my complete code:

 

<apex:page standardController="Manufacturing_Design_Sheet__c" recordSetVar="{!Manufacturing_Design_Sheet__c}" showHeader="true" sidebar="true" extensions="TechContactTrigger"> <style type="text/css"> h1 {font-size: 10pt; text-align: center; font-weight: bolder; font-width: 2 columns; } </style> <apex:form > <apex:pageBlock Title="Manufacturing Design Sheet - Optyx G6 3000" mode="edit" id="thePageBlock"> <apex:pageBlockButtons location="top"> <apex:commandButton value="Update" action="{!save}" rerender="tech" /> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!Delete}"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="2"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Name}"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Opportunity_Name__c}" required="false"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Quotation_Item_Number__c}" required="false"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Account_Name__c}"/> </apex:pageBlockSection> <apex:PageBlockSection title="Contact Information (All Required)" columns="2"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Technical_Contact__c}"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Contact__c}"/> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Phone__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_Fax__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Fax__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_E_mail__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_E_mail__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Ship_To_Address__c}"/> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Invoice_To_Address__c}"/> <apex:inputField value="{!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c}"/> </apex:pageBlockSection> <apex:pageBlockSection > <apex:actionRegion > <apex:outputLabel value="Correct the Information"/> <apex:outputPanel > <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Correct_the_Information__c}"> <apex:actionSupport event="onclick" rerender="thePageBlock" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:actionRegion> </apex:pageBlockSection> <apex:pageBlockSection > <apex:inputField value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}" rendered="{!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c == 'Technical Phone'}"/> <apex:inputField value="{!Manufacturing_Design_Sheet__c.Commercial_Fax__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

When the Technical Phone option is selected, the field Technical_Phone__c is not rendering. I originally formatted the Technical Phone rendered command as

 

...."rendered="{!IF(CONTAINS(Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c,'Technical Phone'), <apex:inputField value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}"/>,"")}"/>

 

Then the next value will be the same and etc.

 

The idea is to only display the fields that are selected in teh multi-picklist to be displayed.

 

Does this help?

bob_buzzardbob_buzzard

I don't think you can test for selected picklist values in this way.

 

I've used the following format:

 

ISPICKVAL($User.UserType,'Guest')

 

 

ckellieckellie

ISPICKVAL doesn't work as this is a multi-picklist rather than just a picklist, or am I mistaken?

ThomasTTThomasTT

According to Visualforce Developer's Guide, INCLUDES is for multi-picklist.

 

and I doubt "onclick" works... I would use "onchange".

 

ThomasTT

ckellieckellie

When I use the INCLUDES function, I receive the following error.

 

"Error: Incorrect parameter for function not(). Expected Boolean, received Text"

 

The field I am referencing is a multi-picklist

ThomasTTThomasTT

I can't see what you did with information you provided... did you use NOT? The message is saysing you used NOT() and used text for the NOT function...

 

We're not a telepath. We need more information to see what's wrong or you need to interprete the error message little bit more...

 

ThomasTT

ckellieckellie

The interesting part of this problem is that the NOT() function doesn't appear anywhere in my code. Here is the code in its entirety:

 

<apex:page standardController="Manufacturing_Design_Sheet__c" recordSetVar="{!Manufacturing_Design_Sheet__c}" showHeader="true" sidebar="true" extensions="TechContactTrigger"> <style type="text/css"> h1 {font-size: 10pt; text-align: center; font-weight: bolder; font-width: 2 columns; } </style> <apex:form > <apex:pageBlock Title="Manufacturing Design Sheet - Optyx G6 3000" mode="edit" id="thePageBlock"> <apex:pageBlockButtons location="top"> <apex:commandButton value="Update" action="{!save}" rerender="tech" /> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!Delete}"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="2"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Name}"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Opportunity_Name__c}" required="false"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Quotation_Item_Number__c}" required="false"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Account_Name__c}"/> </apex:pageBlockSection> <apex:PageBlockSection title="Contact Information (All Required)" columns="2"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Technical_Contact__c}"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Contact__c}"/> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Phone__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_Fax__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Fax__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_E_mail__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_E_mail__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Ship_To_Address__c}"/> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Invoice_To_Address__c}"/> <apex:inputField value="{!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c}"/> </apex:pageBlockSection> <apex:pageBlockSection > <apex:actionRegion > <apex:outputLabel value="Correct the Information"/> <apex:outputPanel > <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Correct_the_Information__c}"> <apex:actionSupport event="onclick" rerender="thePageBlock" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:actionRegion> </apex:pageBlockSection> <apex:pageBlockSection> <apex:pageBlockSectionItem> <apex:inputField value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}" rendered="{!INCLUDEs(!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c,'Technical_Phone__c')}" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

Thanks for your help and patience.
ThomasTTThomasTT
rendered="{!INCLUDEs(!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c,'Technical_Phone__c')}"

 

You don't need this "!" and "!" means NOT().

Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c is not boolean, so ! (NOT) is not appropriate.

 

Now we understand what SFDC is trying to say...

 


ThomasTT

ckellieckellie

Thank you for the tip about the Not function.

 

According to Premier Support, the INCLUDES function is not working with visualforce. As a result, I am using Contains. But the action is not rerendering. Any other thoughts?

ThomasTTThomasTT

"the action is not rerendering" is not enough information... you mean, you are sure that the action is invoked, but re-rendering is failed? or you are not sure that the action is invoked or not?

 

Without those information, I can only "guess". I don't like a guessing game and I'm not a good guess-er. My best guess is that the action is not invoked after you change the selection.

 

As I mentioned, did you try "onchange" rather than "onclick"? I'm not sure when the event is triggered on the multi-select picklist. If it's triggered before or during the user is changing, it's meaningless.

 

 

ThomasTT

ckellieckellie

Here is the code:

 

<apex:page standardController="Manufacturing_Design_Sheet__c" recordSetVar="{!Manufacturing_Design_Sheet__c}" showHeader="true" sidebar="true" extensions="TechContactTrigger"> <style type="text/css"> h1 {font-size: 10pt; text-align: center; font-weight: bolder; font-width: 2 columns; } </style> <apex:form > <apex:pageBlock Title="Manufacturing Design Sheet - Optyx G6 3000" mode="edit" id="thePageBlock"> <apex:pageBlockButtons location="top"> <apex:commandButton value="Update" action="{!save}" rerender="tech" /> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!Delete}"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="2"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Name}"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Opportunity_Name__c}" required="false"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Quotation_Item_Number__c}" required="false"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Account_Name__c}"/> </apex:pageBlockSection> <apex:PageBlockSection title="Contact Information (All Required)" columns="2"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Technical_Contact__c}"/> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Contact__c}"/> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Phone__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_Fax__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Fax__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Technical_E_mail__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Commercial_E_mail__c}" /> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Ship_To_Address__c}"/> <apex:outputfield value="{!Manufacturing_Design_Sheet__c.Invoice_To_Address__c}"/> <apex:inputField value="{!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c}"/> </apex:pageBlockSection> <apex:pageBlockSection > <apex:actionRegion > <apex:outputLabel value="Correct the Information"/> <apex:outputPanel > <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Correct_the_Information__c}"> <apex:actionSupport event="onchange" rerender="thePageBlock" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:actionRegion> </apex:pageBlockSection> <apex:pageBlockSection > <!-- <apex:inputField value="{!Manufacturing_Design_Sheet__c.Technical_Phone_Correction__c}" rendered="{INCLUDES(Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c,'Technical Phone')}" />--> <apex:inputField value="{!Manufacturing_Design_Sheet__c.Technical_Phone_Correction__c}" rendered="{!CONTAINS(Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c,'Technical Phone')}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 

When the checkbox 'Correct the Information' changes value between true and false, the action represented by "applying value..." is displayed as the action script says. Byt the field Technical Phone Correction is not originally hidden as it should be. and is only displaying when the checkbos 'Correct the Information' is toggled.

 

ThomasTTThomasTT

Ok, apex:actionStatus is working, which means action method is called. It seems that rerendering is working. Did you check that the value which you are examining with "CONTAINS" is as expected? Do you know how to check it?

 

In your explanation, you said "When the checkbox 'Correct the Information' changes value..." and that is "Manufacturing_Design_Sheet__c.Correct_the_Information__c", field, but you examine "Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c" with CONTAINS to show/hide the Technical_Phone_Correction__c field.

 

Is that really what you want to do? You capture a change of value, but you don't use the value to re-render something... 

 

and the Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c field is in the different section, and is OUT OF <apex:actionRegion >. I don't think the value is processed when checkbox 'Correct the Information' changes value (not processed means, not set to the variable). If you want to use the value of Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c during re-render, you need to expand actionRegion or remove all actionRegions.

 

 

ThomasTT

 

 

ckellieckellie

ThomasTT wrote:

Ok, apex:actionStatus is working, which means action method is called. It seems that rerendering is working. Did you check that the value which you are examining with "CONTAINS" is as expected? Do you know how to check it?

 


 

I have only checked actionstatuses through guess and check. How do I check it?

 


ThomasTT wrote:

 

In your explanation, you said "When the checkbox 'Correct the Information' changes value..." and that is "Manufacturing_Design_Sheet__c.Correct_the_Information__c", field, but you examine "Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c" with CONTAINS to show/hide the Technical_Phone_Correction__c field.

 

Is that really what you want to do? You capture a change of value, but you don't use the value to re-render something... 

 

and the Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c field is in the different section, and is OUT OF <apex:actionRegion >. I don't think the value is processed when checkbox 'Correct the Information' changes value (not processed means, not set to the variable). If you want to use the value of Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c during re-render, you need to expand actionRegion or remove all actionRegions.

 

 

ThomasTT

 

 


I am not including Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c because the action  method 'deactivates' the picklist to not allow any values to be picked. The logic behind only including Correct_the_Information__c in the action item is to trigger the action, which should run the entire formula and pull from What_Information_needs_to_be_Corrected. Correct_the_Information__c can go away if there is another way to do this.

 

I guess my next question is how do I keep What needs to be corrected working inside the action region?

 

Thank you for your patience.

ThomasTTThomasTT

> How do I check it?

System log and System.debug()... it's much easier than posting a question here... we don't debug with just watching a source code...we try something, analyze the log, and check the source code. Nobody else can run your source code now. You are the only one who can try with working code and see the log...

 

> I am not including Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c because...

I still don't understand why you intentionally used the actionRegion and didn't include  Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c field in it.

 

actionRegion is to limit fields/areas to process. "Process" means getting values from screen and sending them to server. If you don't include a field, it's not stored in the variable in the controller.

 

Another way to make SFDC process a field is to re-render. Add the field into reRender attribute of actionSupport, so that the value will be "processed" and the rendered attribute can examine the latest value of  Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c.

 

ThomasTT

This was selected as the best answer
ckellieckellie
Thank you This works.