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
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 :-)


Regards,
Abhi
Nagendra ChinchinadaNagendra Chinchinada
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}">
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    
</apex:page>

refer below links for more info on rendering,
http://www.infallibletechie.com/2013/03/how-to-display-custom-button-when.html

http://www.infallibletechie.com/2013/04/enabling-and-disabling-pageblocksection.html

http://www.oyecode.com/2013/04/how-to-re-render-part-of-visualforce.html


 
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.

Regards,
Abhi