locked
preventDefault does not working RRS feed

  • Question

  • Hi, 

    I want to cancel save operation in crm 2015 on-premise, i used on function context.getEventArgs().preventDefault().

    Here are the steps:  http://arungeorgejohn.blogspot.co.il/2013/03/crm-2011-rollup-12-javascript-changes.html,

    i try it on activity entity (and i try to disable autosave from setting) but it does not working.

    thank in advence.

    Thursday, June 18, 2015 1:23 PM

All replies

  • Hi,

    Did you pass the context as a parameter to the function and also checked the check-box when you registered your javascript function on save?

    Does it throw any error?

    Add a debugger and check if it gives any error.

    Also could you paste your function , which might help forum users  to debug your issue.

    Thanks,

    Prasad

    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, June 19, 2015 12:03 PM
  • Hi, 

    Yes i pass the context, the debugger does no throw error and here my function:   

    function OnSave(econtext) {
         Xrm.Page.data.setFormDirty();
        if( CheckDuration())

              econtext.getEventArgs().preventDefault();

    }

    thank

    Sunday, June 21, 2015 8:51 AM
  • and where is defined this function CheckDuration() ?

    what is does?


    My blog: www.crmanswers.net - CRM Theme Generator

    Sunday, June 21, 2015 8:53 AM
  • Is check value of a field and return true\false,  I use debug to see that it enter to the "if" and do the command- econtext.getEventArgs().preventDefault();

    its done but  still not works.

    This entity is Activity this could be the reason?

    • Edited by ran-j Sunday, June 21, 2015 10:11 AM
    Sunday, June 21, 2015 10:09 AM
  • Hi,

    Try checking the save mode as given in below blog.

    https://msdn.microsoft.com/en-us/library/gg509060.aspx?f=255&MSPPError=-2147217396

    function preventAutoSave(econtext) {
        var eventArgs = econtext.getEventArgs();
        if (eventArgs.getSaveMode() == 58 || eventArgs.getSaveMode() == 2) {
            eventArgs.preventDefault();
        }
    }
    

    Thanks,

    Prasad

    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


    Monday, June 22, 2015 3:55 AM