Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to keep dialog open when running from Ax JOb

(0) ShareShare
ReportReport
Posted on by

Hi ,

I have a job which opens up a dialog to collect user values for 3 fields.

I am facing 2 issues with it

1>As soon as the user enter value for field 1 & press enter it closes the dialog.

How to ensure that pressing enter does not close  the dialog & how to ensure that user has entered value for all 3 fields.

2>After entering all 3 values and pressing ok the dialog box closes.

How to ensure that dialog clear up teh values & remain open for user to enter next set of records.

  • André Arnaud de Calavon Profile Picture
    294,325 Super User 2025 Season 1 on at
    RE: How to keep dialog open when running from Ax JOb

    Hi Mav,

    Before the select forupdate statement, you can check if all dialog values have been provided. If not, you can raise an error and stop processing. As mentioned above, using other options, you can achieve dialog form validation before the user clicks on OK.

    Also note that if you have sub-projects, then this job can cause data issues as it is not updating sub-projects or checking for consistency.

  • Mav Profile Picture
    on at
    RE: How to keep dialog open when running from Ax JOb

    Hi ,

    Sure here is the code for my dialog.

    static void Job9(Args _args)
    {
        Dialog          dialog;
        DialogGroup     dialogGroup;
        DialogField     dialogfieldLegalEntity,dialogfieldCurProjId,dialogfieldNewProjId;
        ProjTable       projTable;
        ProjId          curProjId,newProjId;
        DataAreaId      dataAreaId;
    
        dialog                 = new dialog ("Update Project ID");
        dialogGroup            = dialog.addGroup("Choose legal entity");
        dialogfieldLegalEntity = dialog.addField(extendedTypeStr(DataAreaId));
        dialogGroup            = dialog.addGroup("Enter Proj id to be updated");
        dialogfieldCurProjId   = dialog.addField(extendedTypeStr(ProjId),"Current Proj Id","Enter current proj id");
        dialogfieldCurProjId.lookupButton(1);
        dialogGroup            = dialog.addGroup("Enter new value for Proj id");
        dialogfieldNewProjId   = dialog.addField(extendedTypeStr(ProjId),"New Proj Id","Enter new proj id");
        dialogfieldNewProjId.lookupButton(1);
    
        try
        {
            if(dialog.run())
            {
                dataAreaId = dialogfieldLegalEntity.value();
                curProjId  = dialogfieldCurProjId.value();
                newProjId  = dialogfieldNewProjId.value();
    
                select  forUpdate  projTable where projTable.ProjId == curProjId && projTable.dataAreaId == dataAreaId;
    
                if (projTable)
                {
                   if (Box::yesNo("Click yes to update the proj id & no to cancel?", DialogButton::No) == DialogButton::Yes)
                   {
    
                        ttsBegin;
                         projTable.ProjId = newProjId;
                         projTable.update();
                        ttsCommit;
                        info("Proj id has been updated to "   projTable.ProjId);
                   }
                   else
                    {
                        info("Update operation canceled by user");
                    }
    
                }
    
                else
                {
                    info("No matching records found, check the entered values & retry");
                }
    
            }
    
        }
    
        catch(Exception::Error)
        {
            info("Caught 'Exception::Error'.");
        }
    
    }

  • André Arnaud de Calavon Profile Picture
    294,325 Super User 2025 Season 1 on at
    RE: How to keep dialog open when running from Ax JOb

    Hi Mav,

    Can you share how you created the job with the dialog? You can add a validation after the dialog closes in the job. If you need more control, you have to create a class for this where you can better control the dialog behavior; eventually with a form as dialog.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,325 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans