web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Unable to store user inputs in dialog

(0) ShareShare
ReportReport
Posted on by

I am using the following code, when i run the dialog i can see the dialog, choose values in it but for some reason no values are saved,i.e. in debugger it shows " " for all my variables in which i m storing the dialog field value.

Pls suggests  how to fix this.

static void ProjIdUpdate(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));
    dataAreaId             = dialogfieldLegalEntity.value();
    
    dialogGroup            = dialog.addGroup("Enter Proj id to be updated");
    dialogfieldCurProjId   = dialog.addField(extendedTypeStr(ProjId));
    dialogfieldCurProjId.lookupButton(1);
    curProjId              = dialogfieldCurProjId.value();
    
    dialogGroup            = dialog.addGroup("Enter new value for Proj id");
    dialogfieldNewProjId   = dialog.addField(extendedTypeStr(ProjId),"New Proj Id","Enter new Proj id");
    dialogfieldNewProjId.lookupButton(1);
    newProjId              = dialogfieldNewProjId.value();
    
    dialog.run();
  
    
    try
    {
        if(dialog.closedOk())
        {

            select  forUpdate  projTable where projTable.ProjId == curProjId && projTable.dataAreaId == dataAreaId;

            if (projTable)
            {
               ttsBegin;
                projTable.ProjId = newProjId;
                projTable.update();
               ttsCommit;
               info("Proj id has been updaated to "   projTable.ProjId);

            }

            pause;
        }
    }

    catch(Exception::Error)
    {
        info("Caught 'Exception::Error'.");
    }

}

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Hi Mav,

    You need to retrieve the dialog values after the dialog was closed with the OK action. Now you do it before the dialog runs, so indeed the values are empty. Try this:

    static void ProjIdUpdate(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));
        dataAreaId             = dialogfieldLegalEntity.value();
        
        dialogGroup            = dialog.addGroup("Enter Proj id to be updated");
        dialogfieldCurProjId   = dialog.addField(extendedTypeStr(ProjId));
        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);
        
        dialog.run();
      
        
        try
        {
            if(dialog.closedOk())
            {
                curProjId   = dialogfieldCurProjId.value();
                newProjId   = dialogfieldNewProjId.value();
    
                select  forUpdate  projTable where projTable.ProjId == curProjId && projTable.dataAreaId == dataAreaId;
    
                if (projTable)
                {
                   ttsBegin;
                    projTable.ProjId = newProjId;
                    projTable.update();
                   ttsCommit;
                   info("Proj id has been updaated to "   projTable.ProjId);
    
                }
    
                pause;
            }
        }
    
        catch(Exception::Error)
        {
            info("Caught 'Exception::Error'.");
        }
    
    }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans