Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

CRM 2013 OnLoad event not triggering after Save.

Posted on by 990

Hello All,

We recently migrated from CRM 2011 to CRM 2013, in CRM 2011 onload events get triggered after save event but the same is not happening in CRM 2013.

*This post is locked for comments

  • Rahul-Waghmare Profile Picture
    Rahul-Waghmare 990 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    None of the solution helped from above link.

    Regards,

    Rahul

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
  • Rahul-Waghmare Profile Picture
    Rahul-Waghmare 990 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    Hi All,

    I have added below function onchange of Modified On field, using below line of code form is getting refreshed,

    function RefreshedAfterSave(){

    Xrm.Utility.openEntityForm("incident", Xrm.Page.data.entity.getId());

    }

    Now, when this function is getting executed I am getting message from webpage.

    ---------------------------

    Message from webpage

    ---------------------------

    Your changes have not been saved. To stay on the page so that you can save your changes, click Cancel.

    ---------------------------

    OK   Cancel  

    ---------------------------

    How to prevent this error message.

    Regards,

    Rahul

  • Suggested answer
    Tushar2016CRM Profile Picture
    Tushar2016CRM 1,130 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    HI ,

    I agree with Santosh , that might be the cause of problem .

    Rahul ,

    Please try to add another refresh in javascript based on form type  (Update),

    Hope it might help

    Thanks

  • Suggested answer
    shivaram Profile Picture
    shivaram 3,315 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    Hi

    Actually, for New Save only Form will save and refresh the Page. For Existing records, if you save the record then Only OnSave Operation will trigger.

    In this scenario OnLoad event will not trigger

  • Rahul-Waghmare Profile Picture
    Rahul-Waghmare 990 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    I have Current Status option-set on form, there are say 10 values present.

    While loading the form  I am checking if the formtype is create then remove all other values and keep only one value as "Assigned". Now once the record is saved I need to show one more option in that as "In Progress" in this case I need to call load event after save or need to refresh the form so that the control goes to the respective function and shows that other value and hide remaining.

    I have added that function on change of modifiedon field which will get changed everytime you save the record.

    While debugging I can see debugger is going inside the function but the changes are not getting reflected on form.

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    Hi Rahul,

    On load event will not be triggered after Save.

    What exactly you are trying to do after save?

    Thanks

    Hemant Sahu

  • shivaram Profile Picture
    shivaram 3,315 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    Got the issue. It will trigger OnLoad and Onload again you are refreshing the page. So it will call infinite times.

    I am saying that

    function OnAfterSave(){

    // Change Status

    }

    This function should call on Modified On

    or else

    function OnSave(){

    // Change Status

    }

    function OnLoad(){

    Var formType=Xrm.Page.ui.getFormType()

    if (formType==2)                // Existing Load

    {

    // Change Status

    }

    }

    Call OnLoad and On Save function Load and Save respectively. Don't refresh the page forcefully.

  • Rahul-Waghmare Profile Picture
    Rahul-Waghmare 990 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    I tried all possible options like

    1. OnSave(context)

    {

     //my logic

     ...

     ...

     Xrm.Page.data.save.then(SuccessOnSave, ErrorOnSave);

    }

     function SuccessOnSave()

    {

     //force refresh

      Xrm.Page.data.refresh();

    }

     function ErrorOnSave()

     {

       //do nothing

     }

    2. Calling OnLoad in OnSave event.

    But in both case its going in infinite loop. I tried the specific function with SetTimeOut method too but that too getting call n number of times.

    Is there any way to check postoperation of event in JS.

  • shivaram Profile Picture
    shivaram 3,315 on at
    RE: CRM 2013 OnLoad event not triggering after Save.

    If we did this then it should work. Okay one thing is there any workflow will run based on this Status?

    If not, you can call this function OnSave and OnExisting Load also

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans