Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

How to keep dialog open when running from Ax JOb

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
    André Arnaud de Cal... 287,696 Super User 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
    Mav 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
    André Arnaud de Cal... 287,696 Super User 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.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans