You need to sign in to do that
Don't have an account?
sweta singh 58
I need to skip all the validations on save command button but html-novalidate="true" html-novalidate=”novalidate” at form level or button level does not work. Also, immediate="true" at command button level is not working.
Hi, sorry if this is a stupid/repetitive question, but I am unable to find appropriate solution for this.
I need to skip all the validations on save command button but
html-novalidate="true"
html-novalidate=”novalidate” at form level or button level does not work.
Also, immediate="true" at command button level is not working.
I also referred to - Nothing works :(
https://wdcigroup.net/salesforce-visualforce-commandbutton-to-bypass-validationrequired-fields/
https://www.biswajeetsamal.com/blog/immediate-true-is-not-working-on-custom-buttons-with-html5-doctype-in-visualforce-page/
<apex:page standardController="opportunityLineItem" extensions="opportunityassetcontroller" id="page1" tabstyle="opportunitylineitem" sidebar="TRUE" lightningStylesheets="true" docType="html-5.0">
<apex:slds />
<body class = "slds-scope">
<apex:form html-novalidate="novalidate" >
<apex:pageMessages />
<apex:pageBlock id="block0" rendered="{!if(NoSubstituteOLIAvail,true,false)}">
<div align="center" draggable="false">
<apex:commandButton value="Close" styleclass="slds-button slds-button--brand" action="{!Close}" immediate="true"/>
</div>
</apex:pageBlock>
<apex:pageBlock id="block1" title="Details" rendered="{!if(NoSubstituteOLIAvail,false,true)}">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Close" styleclass="slds-button slds-button--brand" action="{!Close}" />
<apex:commandButton value="Search" styleclass="slds-button slds-button--brand" action="{!getOliDetails}" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2" id="sec1" title="Opportunity Information" collapsible="false">
<apex:inputField value="{!newopptyLineItem.opportunityid}" />
</apex:pageBlockSection>
</apex:pageBlock>
<br/>
<br/>
<apex:pageBlock id="block2" title="Opportunity Product Details" rendered="{!getolidetails}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" styleclass="slds-button slds-button--brand" action="{!doSave}" />
<apex:commandButton value="Cancel" styleclass="slds-button slds-button--brand" action="{!Close}" immediate="true"/>
</apex:pageBlockButtons>
<apex:pageblockTable value="{!wrapperSelectedOli}" var="wrap" rendered="{!getolidetails}" id="alloli" >
<apex:variable value="{!0}" var="cnt"/>
<apex:column headerValue="Select">
<apex:outputPanel rendered="{!wrap.isSelected}">
<input type="radio" checked="true"/>
</apex:outputPanel>
<apex:outputPanel rendered="{!NOT(wrap.isSelected)}" >
<apex:actionSupport action="{!selectOli}" event="onclick" reRender="alloli" >
<input type ="radio"/>
<apex:param name="index" value="{!cnt}"/>
<apex:param name="olid" value="{!wrap.Oliselect.id}"/>
</apex:actionSupport>
</apex:outputPanel>
<apex:variable var="cnt" value="{!cnt+1}"/>
</apex:column>
<apex:column value="{!wrap.Oliselect.name}"/>
<apex:column value="{!wrap.Oliselect.Ready_For_Service_Date__c}"/>
<apex:column value="{!wrap.Oliselect.End_Contract_Date__c}"/>
<apex:column value="{!wrap.Oliselect.UnitPrice}"/>
<apex:column value="{!wrap.Oliselect.Initial_Cost__c}"/>
<apex:column value="{!wrap.Oliselect.Opportunity.account.name}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</body>
</apex:page>
I need to skip all the validations on save command button but
html-novalidate="true"
html-novalidate=”novalidate” at form level or button level does not work.
Also, immediate="true" at command button level is not working.
I also referred to - Nothing works :(
https://wdcigroup.net/salesforce-visualforce-commandbutton-to-bypass-validationrequired-fields/
https://www.biswajeetsamal.com/blog/immediate-true-is-not-working-on-custom-buttons-with-html5-doctype-in-visualforce-page/
<apex:page standardController="opportunityLineItem" extensions="opportunityassetcontroller" id="page1" tabstyle="opportunitylineitem" sidebar="TRUE" lightningStylesheets="true" docType="html-5.0">
<apex:slds />
<body class = "slds-scope">
<apex:form html-novalidate="novalidate" >
<apex:pageMessages />
<apex:pageBlock id="block0" rendered="{!if(NoSubstituteOLIAvail,true,false)}">
<div align="center" draggable="false">
<apex:commandButton value="Close" styleclass="slds-button slds-button--brand" action="{!Close}" immediate="true"/>
</div>
</apex:pageBlock>
<apex:pageBlock id="block1" title="Details" rendered="{!if(NoSubstituteOLIAvail,false,true)}">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Close" styleclass="slds-button slds-button--brand" action="{!Close}" />
<apex:commandButton value="Search" styleclass="slds-button slds-button--brand" action="{!getOliDetails}" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2" id="sec1" title="Opportunity Information" collapsible="false">
<apex:inputField value="{!newopptyLineItem.opportunityid}" />
</apex:pageBlockSection>
</apex:pageBlock>
<br/>
<br/>
<apex:pageBlock id="block2" title="Opportunity Product Details" rendered="{!getolidetails}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" styleclass="slds-button slds-button--brand" action="{!doSave}" />
<apex:commandButton value="Cancel" styleclass="slds-button slds-button--brand" action="{!Close}" immediate="true"/>
</apex:pageBlockButtons>
<apex:pageblockTable value="{!wrapperSelectedOli}" var="wrap" rendered="{!getolidetails}" id="alloli" >
<apex:variable value="{!0}" var="cnt"/>
<apex:column headerValue="Select">
<apex:outputPanel rendered="{!wrap.isSelected}">
<input type="radio" checked="true"/>
</apex:outputPanel>
<apex:outputPanel rendered="{!NOT(wrap.isSelected)}" >
<apex:actionSupport action="{!selectOli}" event="onclick" reRender="alloli" >
<input type ="radio"/>
<apex:param name="index" value="{!cnt}"/>
<apex:param name="olid" value="{!wrap.Oliselect.id}"/>
</apex:actionSupport>
</apex:outputPanel>
<apex:variable var="cnt" value="{!cnt+1}"/>
</apex:column>
<apex:column value="{!wrap.Oliselect.name}"/>
<apex:column value="{!wrap.Oliselect.Ready_For_Service_Date__c}"/>
<apex:column value="{!wrap.Oliselect.End_Contract_Date__c}"/>
<apex:column value="{!wrap.Oliselect.UnitPrice}"/>
<apex:column value="{!wrap.Oliselect.Initial_Cost__c}"/>
<apex:column value="{!wrap.Oliselect.Opportunity.account.name}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</body>
</apex:page>
Greetings!
I have checked and can see that immediate="true" should bipass all the validation rules.Not sure,why it is not working in your scenario,can you please capture the debug logs and see,which validation rule is firing.
Reference:https://developer.salesforce.com/forums/?id=906F0000000DCaBIAW
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
No, wasn't able to sort it.
Thanks,
Sweta
I found this article today: Immediate=true is not working on custom buttons with HTML5 docType in Visualforce Page (https://www.biswajeetsamal.com/blog/immediate-true-is-not-working-on-custom-buttons-with-html5-doctype-in-visualforce-page/).
Can you try with html-formnovalidate="formnovalidate" on your apex:commandButton?