locked
How to stop a page saving? RRS feed

  • Question

  • Hi,

     

    I've a date field on a page. It is a required field. I want to check that this field should not have date less than current date on Save event of Form. If user enters some previous date, then it should give and error and should not save the record.

     

    I've applied the check and set the date value to null if user enters some wrong date. But even if user enters a wrong date, it gives alert('error message'); and closes the form successfully, which date field set to null. Having it as a required field, it should not save null in this field. Rather it should remain on the same form after giving error. Whereas it saves record with null in that perticular date field.

     

    please help me resolving this issue.

    Thursday, February 7, 2008 7:56 AM

Answers

  • From memory I believe you need to add the following code to the appropriate part of your form's onSave event:

     

    Code Snippet

    // suppress the form's save event

    event.returnValue = false;

     

     

    Best wishes

     

    Greg Owens

    My Blog: The CRM Grid

    Thursday, February 7, 2008 9:13 AM

All replies

  • dear, for one of my code, I save form using javascript

     

    if(strRole == 'Adminstrator')
      {
       crmForm.Save();
      }
      else
      {
       crmForm.SaveAndClose();
      }

     

    you can try your luck.

     

    Regards,

    Imran

     

    http://microsoftcrm3.blogspot.com

     

    Thursday, February 7, 2008 8:10 AM
    Moderator
  • But what if i want to stop form saving? will crmForm.Save = False; work?

     

    Thursday, February 7, 2008 8:19 AM
  • From memory I believe you need to add the following code to the appropriate part of your form's onSave event:

     

    Code Snippet

    // suppress the form's save event

    event.returnValue = false;

     

     

    Best wishes

     

    Greg Owens

    My Blog: The CRM Grid

    Thursday, February 7, 2008 9:13 AM
  • Thanks Greg. Your suggested solution works.

    Thursday, February 7, 2008 11:07 AM