+ Start a Discussion
Abhishek NagarajAbhishek Nagaraj 

Trigger on Checking the Check Box.

I have a situation as below.

I have an object OBJECT 1 and couple of fields in it. Two Fields among them are Field1 [Check Box] and Field2 [Date Field]. When I create a new record for OBJECT 1, I want Field2 to be read only and on checking the Field 1 to true, I want Field 2 to be visible and Editable. I tried using WF rules but It didn't work as the rules applied only after saving the record. I want while filling the details while creating new record. 
Flow would be,
1: Click New Record Button on Object 1
2: You see Field 2 is read only.
3: You check Field 1 to true
4: And you want Field 2 to be visible and editable now.
5: User picks the date in Field 2 and saves the record.

I beleive it is possible using Triggers But I want help in creating and achieveing using Triggers. I am asking this as I am two weeks old in Salesforce :-)

Nagendra Prasad ChNagendra Prasad Ch
Hi Abhishek,

For this you would need a VisualForce page, rendered, rerender functions in visualforce page. Here is the example VF page.
<apex:page >
    <apex:form >
        <apex:pageBlock Title="pgBlock">
            <apex:pageBlockSection id="pageBlksect">
			<!-- check box field -->
                <apex:inputField  value="{!Object1.CheckboxField1}" id="checkedone">
                <apex:actionSupport event="onclick" rerender="pageBlksect"/></apex:inputCheckbox>
				<!-- Date field -->
                <apex:inputField  value="{!Object1.DateField2}" rendered="{!Object1.Field1}">

refer below links for more info on rendering,



Abhishek NagarajAbhishek Nagaraj
Hi Nagendra,
Thank you so much for your answer. I will try this and update you. Thanks again for the detailed answer.