web
You’re offline. This is a read only version of the page.
close
Skip to main content
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.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    299,353 Super User 2025 Season 2 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.

  • 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
    299,353 Super User 2025 Season 2 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.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,047

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 885 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 592 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans