Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Unsaved changes alert is showing twice on custom entity in CRM 2016

Posted on by Microsoft Employee

On custom entity when we try to set lookup and navigate to selected lookup then form should alert user that there are unsaved changes please save before navigating.

But Unsaved changes alert is displayed two times("Ok"  & "Cancel")

Why it is showing twice in CRM 2016 on specific entity.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unsaved changes alert is showing twice on custom entity in CRM 2016

    Thanks for your suggestion Goutam

    I am selecting new value on lookup field and then navigating page without saving form and it uses crm redirection on hyperlink.

    I also verified there are no fields on form getting "IsDirty" other than lookup field and can you please tell me scenario when there is possibility of multiple alerts.

    Also I identified the root cause "TurboForm Rendering".

    Please suggest me how to resolve issue without disabling "TurboForms"

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unsaved changes alert is showing twice on custom entity in CRM 2016

    Idenitified the root cause for the issue.

    We have enabled "TurboForms" on CRM Organization due to which it is causing issue.

    Please let me know how to resolve issue without disabling TurboForms

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Unsaved changes alert is showing twice on custom entity in CRM 2016

    Hi Praveen,

    For my understanding yes it should be once , but it depends on what action you are doing . Let say I am viewing one contact record and then I am moving account record using  top navigation  in that case alert should be show once.

    But from your case are you are changing lookup and then how your are navigating I am not clear ? 

    To make this fix  try to write like below in the onchange of lookup-

    function OnChangeLookup() {
        Xrm.Page.data.save().then(successSubmitCallback(), errorSubmitCallback);
    }
    function successSubmitCallback() {  
        //get lookpid 
        setTimeout(function () { // Put some timeout to set the lookup and the it will redirect
            Xrm.Utility.openEntityForm("lookupentityname", lookpid, null, null);     
        }, 500);   
    }
    function errorSubmitCallback(message) {
        alert("error");
    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unsaved changes alert is showing twice on custom entity in CRM 2016

    If any field of form gets "IsDirty" then alert for Unsaved Changes should come once not for each field on form

    Please let me know what is causing issue and field is Lookup Field

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Unsaved changes alert is showing twice on custom entity in CRM 2016

    Hi Praveen,

    This error is coming when you are changing some field value in client side and forms become dirty and unable to redirect to update form until and unless you saved the data. You can check with  below code to get the field name if you are not aware about which fields are changed but not  saved.

    //get list of dirty fields
    var entAttributes = Xrm.Page.data.entity.attributes.get();
     
    if (entAttributes != null) {
        for (var i in entAttributes) {
            if (entAttributes[i].getIsDirty()) {
                listofDirtyAttri += entAttributes[i].getName() + "\n";            
            }
            alert(listofDirtyAttri);
        }
    }

    When you are changing field from client side make sure you did setsubmit mode = always.

    Xrm.Page.getAttribute("FieldName").setSubmitMode("always")


    Once you change the field don't forget to call -

    Xrm.Page.data.save()
    

    Hope this helps.

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: Unsaved changes alert is showing twice on custom entity in CRM 2016

    Hi Praveen

    Do you have any JavaScript on the form that sets values for other fields?

    You can retrieve a list of the dirty fields (fields that were modified) and see which one is causing the 2nd alert. See following links for help:

    nishantrana.me/.../get-the-list-of-all-the-dirty-fields-in-the-form-in-dynamics-365

    community.dynamics.com/.../identify-dirty-fields-on-microsoft-dynamics-crm-form

    Hope this helps,

    Radu

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans