Activity Forums Salesforce® Discussions How immediate attribute work on CommandLinks and CommandButtons in Salesforce?

  • madhulika shah

    Member
    August 20, 2018 at 9:03 am

    Hi Parul,

    By setting immediate to true, validation rules are skipped and the action associated with the CommandLinks and CommandButtons is executed immediately.

    You can write it like this:

    <apex:CommandLink action="{!cancelApplication}" value="Cancel" styleClass="btn" id="btnCancel" immediate="true">

  • shariq

    Member
    September 16, 2018 at 12:56 pm

    Hi,

    Visualforce Immediate Attribute on CommandLinks and CommandButtons Technical Explanation :-

    • When we don’t want the validation rule to be fire during server request we set this attribute Immediate=”true”.
    • Default value of this immediate attribute is false.
    • When we are having functionality of Back to previous page or cancel button, where we don’t our validation rules to be fired. In this case if we didn’t set Immediate=”true” where validation rule will get fired and we end up in a state of unable to return to previous page.To avoid this case we need to set Immediate=”true” like below Visualforce Immediate Attribute on CommandLinks and CommandButtons example.

    <apex:CommandLink action="{!cancelMethod}" value="Cancel Link" styleClass="btn" id="btnCancel" immediate="true">

    <apex:commandButton value="Cancel" immediate="true" action="{!cancelbutton}"/>

    • We usually wire this attribute in cancel button to skip validation rules.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos