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
Everton CP7Everton CP7 

Invisible Fields

Hi there,

 

I'm new in Apex, so I'm facing a few challenges in developer.

 

I have a picklist with a few options to choose.

Depending what option you choose in picklist a rule forces you to write in text field. So I already did a VR in the fields.

 

But what I really need in this fields is that they have to remain invisibles until user choose a option in picklist.

And I tryed programming this:

 

trigger Campos_Em_Branco on Case (before insert) {
//1.Dados de retorno is blank until I choose Motivo = Cheque devolvido
<apex:motivo__c value=Cheque devolvido>;
<apex:actionSupport action=On Case reRender=Dados de retorno/>;
</apex:motivo__c>;
<apex:motivo__c value=Cheque devolvido id=Dados_de_retorno__c rendered={!putaBooleanFlagifFieldisChanged} >
}

 

A friend sent the programming and I edit some things.

I think I'm in the right way.

But the programming still giving errors.

 

Can someone help me? What I'm doing wrong?

 

Thanks for help,

Everton.

Best Answer chosen by Admin (Salesforce Developers) 
SimonJaiSimonJai

I don't think you will need to create a controller, you should be able to do it all in VF.

 

I think this is what you are looking for http://boards.developerforce.com/t5/Visualforce-Development/Render-based-on-the-picklist-Value-selection/m-p/253057#M32973 .

 

Essentially what you want to do is use the rerender attribute to tell VF what to rerender, and set the correct condition for the rendered tag for the text field. So when the picklist changes it will rerender the section with the text field, and if the rendered condition is fulfilled then the text field will render/appear.

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm

All Answers

SimonJaiSimonJai

This is a Trigger is on the controller layer.

trigger Campos_Em_Branco on Case (before insert) {

 

Everything below is VF and is on the view layer.

<apex:motivo__c value=Cheque devolvido>;

 

You cannot use triggers inside a VF page...

Everton CP7Everton CP7

How can I do the code that I need?

 

There is a way to put the trigger in VF?

Or I have to do another code?

SimonJaiSimonJai

I don't think you will need to create a controller, you should be able to do it all in VF.

 

I think this is what you are looking for http://boards.developerforce.com/t5/Visualforce-Development/Render-based-on-the-picklist-Value-selection/m-p/253057#M32973 .

 

Essentially what you want to do is use the rerender attribute to tell VF what to rerender, and set the correct condition for the rendered tag for the text field. So when the picklist changes it will rerender the section with the text field, and if the rendered condition is fulfilled then the text field will render/appear.

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm

This was selected as the best answer
Everton CP7Everton CP7

Okay, I read somethings.

 I was trying do the code in the wrong place.

 

Lets see.

I started do coding in "Pages"

I changed the code to:

 

<apex:page standardController="case">
<apex:inputField value="motivo__c" >
<apex:actionSupport action="OnChange" reRender="Dados de retorno"/>
</apex:inputField>
<apex:inputField value="" id="Dados_de_retorno__c" rendered="{!Cheque Devolvido}" >
</apex:page>

 

But appears an error and I can't resolve this.

"Attribute value in <apex:inputField> must contains only one formula expression wich is resolved for only one variable or controller method."

 

Sorry for the noob questions.

But I'm a noob in this, hahaha..

 

Thanks Simon,

SimonJaiSimonJai

<apex:inputField value="" id="Dados_de_retorno__c" rendered="{!Cheque Devolvido}" >

 

The value attribute cannot be empty, otherwise SF does not know what to show. You need to tell SF which field you want.

 

<apex:inputField value="{!Case.Name}" id="Dados_de_retorno__c" rendered="{!Cheque Devolvido}" >

Everton CP7Everton CP7

Thank you so much Simon !

 

I followed the link you sent me and I created a page.

 

I have another doubts.


I want a button to open a new case and other to close case.

Can I assign this buttons using code? Which code do I use?

As you can see. I created 2 buttons. "Save" and "Cancel" just for test.

 

My pick list field "Motivo" have several options and the only option that appears in there is "Outro Motivo".
How I put another options?

 

How I add the page to use in my cases?
I have some "Record Types". Can I assign my page to one specific "Record Type"?

 

 

 

<apex:page standardController="Case">
      <apex:form >
          <apex:pageBlock title="Caso Cobrança" mode="edit">
              <apex:pageBlockButtons location="bottom">
                  <apex:commandButton value="Salvar" action="{!Save}"/>                
                  <apex:commandButton value="Cancelar" action="{!Cancel}" immediate="true"/>                                
              </apex:pageBlockButtons>
              <apex:pageBlockButtons location="top">
                  <apex:commandButton value="Salvar" action="{!Save}"/>
                  <apex:commandButton value="Cancelar" action="{!Cancel}" immediate="true"/>                                
              </apex:pageBlockButtons>
				<apex:PageblockSection columns="1" >
                    <apex:inputField value="{!Case.Status}"/>
                    <apex:PageBlockSectionItem >
                        <apex:outputLabel value="Motivo"/>
                        <apex:actionRegion >
                            <apex:inputField value="{!case.motivo__c}">
                                <apex:actionSupport event="onchange" reRender="ajaxrequest" />                            
                            </apex:inputField>
                        </apex:actionRegion>
                    </apex:PageBlockSectionItem>
				</apex:PageblockSection>
			<apex:outputPanel id="ajaxrequest">   
					<apex:pageBlockSection rendered="{!Case.motivo__c=='Cheque Devolvido'}" >
                      
				<apex:inputField value="{!case.dados_de_retorno__c}"/>
                    </apex:pageBlockSection>
            </apex:outputPanel>
                 <apex:PageblockSection columns="1" >
					<apex:inputField value="{!Case.subject}"/>
                  		<apex:PageBlockSectionItem >                
                         	<apex:outputLabel value="Descrição"/>
                      			<apex:actionRegion >
                    <apex:inputField value="{!case.description}">
					</apex:inputField>
                         		</apex:actionRegion>
                      	</apex:PageBlockSectionItem>
                </apex:PageblockSection>
           </apex:pageBlock>
      </apex:form>
</apex:page>

 

Thanks again Simon !

Everton CP7Everton CP7

Forget about the buttons.

I see how it works.

 

Sorry Simon and thanks for your attention.