web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to: setFormDirty method question.

(0) ShareShare
ReportReport
Posted on by 68

Hi,

I'm trying to understand how setFormDirty method works. Didn't find description of it in SDK, got couple samples from internet, but still not clear. What I'm trying to achieve: I want to mark form like it has some Unsaved Changes.

function SomeFunction()
{
        alert(Xrm.Page.data.entity.getIsDirty());        
        Xrm.Page.data.setFormDirty(true);
        alert(Xrm.Page.data.entity.getIsDirty());
}

In both alerts I'm getting False. Looks like I'm using setFromDirty method in a wrong way. If so, any other suggestion?

Or the only way it's to change some field on the form, so it will be marked for AutoSave?

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Karth Profile Picture
    on at

    Try using Xrm.Page.data.setFormDirty() instead of Xrm.Page.data.setFormDirty(true);

  • Alex.P Profile Picture
    68 on at

    Thanks for reply Karth, but it's not working as well.

    To be more clear - I'm talking about text at the bottom of the form:

  • Alex.P Profile Picture
    68 on at

    Any other ideas? Thanks.

  • Community Member Profile Picture
    on at

    As Alex's graphic above shows, is there any way to trigger the unsaved changes prompt in the lower right of the page?  I've tried Xrm.Page.data.setFormDirty() and Xrm.Page.data.setFormDirty(true) without success on Crm Online.

  • Community Member Profile Picture
    on at

    Hello Alex,

    I'm trying to figure out why you are trying to set de form dirty, if you can tell us why, we can provide you an alternative,

    Regards.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Arjay248,

    I don't believe we have any method setFormDirty available to use under Xrm.Page.data. The only methods available are save & referesh-

    msdn.microsoft.com/.../dn481607.aspx

    Also, if you check the description of Xrm.Page.data.entity.getIsDirty() , it will check if there is any field which is dirty.

    msdn.microsoft.com/.../gg334720.aspx

    So I would say to achieve this, you need to set some field (it could be any field) as dirty using setSubmitMode

    msdn.microsoft.com/.../gg334409.aspx

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks for all the replies.  I had seen setFormDirty in existing client code in the project I'm working on and assumed it was still supported (I believe the code base I'm working on was a port of the on-premises version).  At any rate, I'm a bit surprised that the setFormMethod is still is part of the Xrm but is a noop.  At any rate, my problem is that I have a subgrid on a page with some custom js that displays checkboxes in a column (yeah, I know about unsupported client side scripting, but work still needs to get done), When a user clicks on the column, I want the user to be prompted to save so that a plugin gets triggered on the page with the subgrid and processes the subgrid record changes.  Using the setSubmitMode, I was able to get the plugin to trigger when the subgrid checkboxes were changed.  

    Thanks all.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    Glad it worked for you. Please close the thread by marking it as helpful/verrified.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans