1

I am trying to achieve a functionality where GST no field should be mandatory when IST flag is set to yes.Below piece of code didnt work for me . Also I cannot use Javascript for some reason

 <div class="col s12 m6 l6">
                                <div class="slds-form-element__control">
                                    <!--<apex:image id="theImage8" value="{!$Resource.StarIcon}" width="5px" height="5px" alt="Description of image here"/>-->
                                    <apex:inputField value="{!Lead.Is_GST__c}" required="true" id="IsGSTID"  styleClass="slds-input">
                                    </apex:inputField>
                                </div>

                            </div>

                            <div class="row ">
                                <div class="input-field col s12 m6 l6">
                                    <div class="slds-form-element" id="ProGSTRegisNo">

                                        <div class="slds-form-element__control">
                                            <!--<apex:image id="theImage11" value="{!$Resource.StarIcon}" width="5px" height="5px" alt="Description of image here"/>-->
                                            <label>Provisional GST Registration Number</label>
                                            <apex:inputField required="{!IF(Lead.Is_GST__c = 'Yes',True,False)}" value="{!Lead.Provisional_GST_Registration_Number__c}" id="GSTRegistrationNumberId" styleClass="slds-input" />
                                      <div id="err51"></div>
                                        </div>
                                        <div id="err13"></div>
                                    </div>
                                </div>
0

I guess adding actionSupport is not enough, you also need to rerender your input. The solution that should work is provided here by Glyn Anderson: https://developer.salesforce.com/forums/?id=906F00000008y1ZIAQ

| improve this answer | |
  • Thank you @Andrei . It worked for me – Kathy M Apr 19 at 9:44
0

All you need to do at this point is add apex:actionSupport:

<apex:inputField value="{!Lead.Is_GST__c}" required="true" id="IsGSTID"  styleClass="slds-input">
    <apex:actionSupport event="onchange" />
</apex:inputField>
| improve this answer | |
  • Thanks for your answer, but validation is still not working. It allows me to save the lead form even if i keep GST number field blank and IsGST flag is set to true. – Kathy M Apr 18 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.