Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Need Help in Dexterity

Posted on by 515

I need help from Dex experts. I want to show a model window and stop processing current script till the model window gets close. Can anyone guide me how should I do this?

I found "open form FormName return to FieldName". This needs a field to return a value but I am opening form from a script.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need Help in Dexterity

    Hi Vaid,

    I am having the same request.

    Have you got with an idea to accomplish this.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need Help in Dexterity

    I came up with an approach for this very issue. Since I was unable to format the message text in the ask() function, I too needed to try and use a normal dexterity window (modal window type) to to give the user a better visual experience in the UI (name/value pairs separated by newlines).

    I created the window as part of the form where the business logic resides (i.e. I did not create a separate form/window combination for the modal window). I really can't say if this approach is generic enough to use in all cases, but what I did was refactor the dexterity code where I needed to have a modal window, such that the 'open window' statement was the last statement in the current code path.  I placed the refactored business logic into a new form procedure to be called later from a change script associated with the original field. To call  the change script I used 'run script delayed' from the modal window's post script thus allowing the modal window to close before the change script is run and thus being able to execute the business logic contained in the new form procedure.

    Now, since modal windows usually return something that controls the flow of code,  my Yes/No buttons on the modal window had code that updated another local field on the original window which was then used by the original script to execute the operate behavior.

    I hope this wasn't too confusing. It sure was a lot of work to simulate what is normal Window's modal (e.g. the ShowDialog method in .Net or DoModal in C++ CDialog class) behavior in other environments.

    Of course all this could have been avoided if only I would have had the ability to create formatted text in that dexterity ask() function.

    I am sure there are many other solutions to such dilemma's but finding design solutions in dexterity beyond what is contained in the manuals is very challenging. Certainly not like googling around the net for solutions in other languages and frameworks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need Help in Dexterity

    Yes. This is quite normal with Dex. Once a process is initiated, it continues with the code flow. The only way to halt the flow is to have a dialog box. But in your case you need three values as input from customer. Hmm...

    Let me think over this.

  • ram shenkar Profile Picture
    ram shenkar 515 on at
    RE: Need Help in Dexterity

    Thanks I am able to open this window now.

    Coming back to my original issue.

    I don't want to execute code after open window statement unless and until window is close. In short same behaviours as line ask() function.

    What I observe is window gets open but it will continue to execute next statement without waiting for response from the window. Hope I am able to explain you it properly.

    For more information, following code snippets  shows my sample code.

    Here, I don't want to execute "End Process" unless and until TestMessageBox gets close. But what I observed is both my custom window and warning message are seen at a time on screen, that means code gets executed after open form statement.

    Please let me know if I am missing something. 

  • Suggested answer
    soma Profile Picture
    soma 24,406 on at
    RE: Need Help in Dexterity

    If you set AutoOpen False to all windows inside the form TestMessageBox, then you can just use the below script.

    open form TestMessageBox ;

    open window TMsgBox of form TestMessageBox as modal;

    Hope this helps!!!

  • Suggested answer
    soma Profile Picture
    soma 24,406 on at
    RE: Need Help in Dexterity

    Otherwise you can use the below coding for the same without modifying anything on the window property.

    open form TestMessageBox ;

    open window TMsgBox of form TestMessageBox as modal;

    call remote closeTestMessageBox ;

    Then create new script closeTestMessageBox for closing this form TestMessageBox.

    {closeTestMessageBox }

    close form closeTestMessageBox;

    Hope this helps!!!

  • Suggested answer
    soma Profile Picture
    soma 24,406 on at
    RE: Need Help in Dexterity

    How many windows inside the form TestMessageBox?

    First you should open your form TestMessageBox. Then only you can open the window TMsgBox inside attached to the form TestMessageBox. Otherwise you can not open the window.

    Better you follow the below steps to achieve your requirement.

    1. In the Form definition, open the form and select TMsgBox under the window section and click Set Main.

    2. Open the window TMsgBox, then set AutoOpen to TRUE & Window Type to "Modal Dialog".

    3. Then call the open form script. It will automatically open your window TMsgBox.

    open form TestMessageBox.

    Note: Don't add any more windows to this form TestMessageBox. Because, if you call the open form script in any other places of your project, it will open the window which having set to AutoOpen, means it will automatically open this TMsgBox window.

    Hope this helps!!!

  • ram shenkar Profile Picture
    ram shenkar 515 on at
    RE: Need Help in Dexterity

    I tried this 

    "open window TMsgBox of form TestMessageBox as modal"

    but I am getting error "Cannot open window"

    I am calling this from a global script.  Did I miss something ?

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need Help in Dexterity

    So correct me if I am wrong. Customer is required to enter 3 different values on 3 fields and then pass these values to the next process/window/form. It's not just one field, if so we could have used ask().

    Soma was right. You can do away with one button by passing a blank value. But if above is what your requirement is, then ask() is not the way to go.

    You may then try opening the window (with 3 fields and 2 buttons) with following code:

    open window <window_name> of form <form_name> as modal;

    This will open any window as modal dialog window and will not proceed further till user responds to this window and close it appropriately.

    Hope this helps.

    P.S.: Thanks for the feedback on my blog. Highly appreciated.

  • Suggested answer
    soma Profile Picture
    soma 24,406 on at
    RE: Need Help in Dexterity

    Hi Ram,

    Vaidy suggested a good idea for your requirement. You can follow the same.

    Addition to above your requirement, you can use two buttons (pass empty "" to the third  parameter, it won't show the third parameter values as button) in ask().

    Example:

    ask("Do you want to save this item?","Yes","No","");

    Hope this helps!!!

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans