You need to sign in to do that
Don't have an account?
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.
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
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...
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?
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
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,
<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}" >
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"?
Thanks again Simon !
Forget about the buttons.
I see how it works.
Sorry Simon and thanks for your attention.