Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to Save form using javascript in Dynamics 365?

Posted on by Microsoft Employee

Hi People,

I am using "next stage" button in Business process flow,  with clicking next stage button i am setting optionset value.  But after saving once, it shows "unsaved changes". I have used "Xrm.Page.data.entity.save();". which is not working. Someone PLEASE help, its urgent.

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Save form using javascript in Dynamics 365?

    Try adding a flag. For example,

    var count = 0;

    if(count == 0)

    {

    //your code

    count ++;

    Xrm.Page.data.entity.save();

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Save form using javascript in Dynamics 365?

    if(ExecutionContextObj.getEventArgs().getDirection()==="next")

     {

         // Set optionset value

         Xrm.Page.data.entity.save();

     }

    when i'm applying above stated code it is going in infinite loop of saving. i don't think this is going to work.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Save form using javascript in Dynamics 365?

    yes

  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: How to Save form using javascript in Dynamics 365?
    Are you doing something like this: 

    Xrm.Page.data.process.addOnStageChange(onStageChange); function onStageChange() { if(ExecutionContextObj.getEventArgs().getDirection()==="next") { // Set optionset value Xrm.Page.data.entity.save(); } }


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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans