Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Double action button issue.

Posted on by Microsoft Employee

Hi everybody, 

I have customized double actions that have to first run a workflow and secondary save and close the page. 

I do it like this:

1 - Create a New Button on RibbonWorkbench

2- Add the first Action: Javascript Command: RuningMyWorkflow with the string parameters of my Workflow.

3- Add a second Action: Javascript Command based on my script function to save and close my page ( like this :function SaveAndClose() {
       Xrm.Page.data.save().then(ClosePage, function () { });
}
function ClosePage()
{
    Xrm.Page.ui.close();
 }

And it works ... almost works :(

Indeed separately the 2 actions work well ( test on a different button ).

But together, the second action is too fast for the first. What I mean is: when I click on my button I have just enought time to see the window to run my workflow than the page is save and closed. 

What I'm looking for a solution to have my first action proceed ,and after the save and close

Thank for your help !

Natsirt

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Double action button issue.

    I don't use javascript code for my first action. I just call the guid of my workflow on a ribbonworkbench command.

    I finally find a solution.  Bellow the code, i use to my second action using a flag field ( it's take value "OK" in the workflow)

    function SaveAndClose()

    {      

          Xrm.Page.getAttribute("cap_flag_fa").setValue(null);

          Xrm.Page.data.save().then(VerifBoolean, function () { });

    }

    function VerifBoolean()

    {

    if( Xrm.Page.getAttribute("cap_flag_fa").getValue("OK"))

    {

    Xrm.Page.ui.close();

    }

    else

    {

           Xrm.Page.data.refresh();

    setTimeout(VerifBoolean,1000);

    }

    }

    function ClosePage()

    {

    Xrm.Page.ui.close();

    }

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Double action button issue.

    Hi Natsirt,

     could you post your javascript code for the first action?

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