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'.");
    }

}

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    292,884 Super User 2025 Season 1 on at
    RE: Unable to store user inputs in dialog

    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February 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... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,754 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans