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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Base on Dialog Button click table field get data

(0) ShareShare
ReportReport
Posted on by 2,430

Dear Gents,

what i am trying here i wrote clicked method it has dialog button as following.

i want to replace Dialog Button "Yes" to "Cash" and "No" to "Card".

then in if() {} statement i want to store either Cash or Card in a Table.

How can i achieve please guide me.

void clicked()

{

DialogButton diaBtn;
;
diaBtn=Box::yesNo("Choose Payment Option",DialogButton::Yes,"Cash or Card","Payment");

if(diaBtn==DialogButton::No || diaBtn==DialogButton::Yes)

{

Table.Field=diaBtn;

}

}

*This post is locked for comments

I have the same question (0)
  • Ashraf Shorman Profile Picture
    100 on at

    Design new form, as a dialog.

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Use the following code in your clicked method.

    Dialog dlg = new Dialog();
    DialogGroup dlgGroup;
    formBuildCommandButtonControl cancelButton, okButton;

    dlg.addText("How would you like to do the payment?");
    cancelButton = dlg.dialogForm().buildDesign().control('CancelButton');
    okButton = dlg.dialogForm().buildDesign().control('okButton');
    okButton.text("Cash");
    cancelButton.text("Card");

    if(dlg.run())
    {
    //dataSource.field = "Cash"
    info("yes");
    }
    else
    {
    //dataSource.field = "CardNumber"
    }

    It appears like this:

    Dialog.jpg

    Please mark answer as verified, if you feel your issue is resolved.

    Thanks,

    Chaitanya Golla

  • faiz7049 Profile Picture
    2,430 on at

    Thanks Golla,

    In my scenario i have only if condition without else because salesman can select either Cash or Card but it should go if condition only(If condition is same for Card or Cash means no else block).  i want to do on button selection dataSource.field store "Cash" or "Card"  

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    As per my understanding, you provide two options to the user namely Cash or Card, based on user selection you either store cash amount or card number.

    As you mentioned that you want change Ok button to Cash and Cancel button to Card, the user can select only one option i.e either Cash or Card, provided the above code.

    Then you can rewrite the same code as:

    if(dlg.run() == true || dlg.run() == false)

    {

    //dataSource.field1 = Cash or Card;

    }

    Let me know if I miss anything.

    Thanks,

    Chaitanya Golla

  • faiz7049 Profile Picture
    2,430 on at

    Dear Golla,

    below is the source code and i created one string filed in Table buffer custInvoiceJour . Once dialog clicked i want to store "CASH" or "CARD" button text in custInvoiceJour field with respect to SalesOrder Id.

    Please review the source code i get back to me what i am missing or how to get it done.

    void clicked()

    {

       SalesFormLetter_Invoice     _invoice;

       SalesFormletter             SalesFormletter;

       SalesTable                  _SalesTable;

       CustInvoiceJour             custInvoiceJour;

       HCSSalesInvoiceController   controller;

       HCSSalesInvoiceContract     contract;

       Args                        args;

       Dialog dlg = new Dialog();

    DialogGroup dlgGroup;

    formBuildCommandButtonControl cancelButton, okButton;

    dlg.addText("How would you like to do the payment?");

    cancelButton = dlg.dialogForm().buildDesign().control('CancelButton');

    okButton = dlg.dialogForm().buildDesign().control('okButton');

    okButton.text("Cash");

    cancelButton.text("Card");

    ;

    if(dlg.run()))

           {

       _SalesTable = SalesTable::find(SalesTable.SalesId);

       _invoice = SalesFormLetter::construct(DocumentStatus::Invoice);

    custInvoiceJour.Field="Dialog Button Text";

       // Post the invoice of SO

       _invoice.update(_SalesTable, SystemDateGet(), SalesUpdate::All,AccountOrder::None, false, false);

       // Print the report

       select firstOnly custInvoiceJour where custInvoiceJour.SalesId == SalesTable.SalesId;

       args = new args();

       args.record(custInvoiceJour);

       controller = new HCSSalesInvoiceController();

       contract   = new HCSSalesInvoiceContract();

       controller.parmArgs(args);

       controller.parmReportName(ssrsReportStr(HCSSalesInvoiceReport, MIReport));

       controller.prePromptModifyContract();

       controller.parmShowDialog(false);

       contract.parmRecId(custInvoiceJour.RecId);

       controller.parmReportContract().parmRdpContract(contract);

       controller.startOperation();

       }

       }

  • faiz7049 Profile Picture
    2,430 on at

    Anybody can help me?

  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi,

    _SalesTable = SalesTable::find(SalesTable.SalesId);

    In this line which salesid (Where you are mentioning salesid ).

    Please provide exact code.others can help you.

    Regards

  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Let me know if understanding is correct.

    You will provide two options to the user with cash and credit.

    Based on the user input you either store the text as cash or credit and proceed further with your later process. If so, please update your code as following.

    void clicked()

    {

      SalesFormLetter_Invoice     _invoice;

      SalesFormletter             SalesFormletter;

      SalesTable                  _SalesTable;

      CustInvoiceJour             custInvoiceJour;

      HCSSalesInvoiceController   controller;

      HCSSalesInvoiceContract     contract;

      Args                        args;

      Dialog dlg = new Dialog();

      DialogGroup dlgGroup;

      str inputvalue; // declare this variable

      formBuildCommandButtonControl cancelButton, okButton;

      dlg.addText("How would you like to do the payment?");

      cancelButton = dlg.dialogForm().buildDesign().control('CancelButton');

      okButton = dlg.dialogForm().buildDesign().control('okButton');

      okButton.text("Cash");

      cancelButton.text("Card");

      ;

      if(dlg.run()) // Run method gets called on clicking Ok button, in our case its cash.

     {

       inputValue = "Cash";

      }

     else

    {

       inputValue = "Credit";

    }

      SalesTable = SalesTable::find(SalesTable.SalesId);

      _invoice = SalesFormLetter::construct(DocumentStatus::Invoice);

      custInvoiceJour.Field= inputValue; // Capturing dialog text

      // Post the invoice of SO

      _invoice.update(_SalesTable, SystemDateGet(), SalesUpdate::All,AccountOrder::None, false, false);

      // Print the report

      select firstOnly custInvoiceJour where custInvoiceJour.SalesId == SalesTable.SalesId;

      args = new args();

      args.record(custInvoiceJour);

      controller = new HCSSalesInvoiceController();

      contract   = new HCSSalesInvoiceContract();

      controller.parmArgs(args);

      controller.parmReportName(ssrsReportStr(HCSSalesInvoiceReport, MIReport));

      controller.prePromptModifyContract();

      controller.parmShowDialog(false);

      contract.parmRecId(custInvoiceJour.RecId);

      controller.parmReportContract().parmRdpContract(contract);

      controller.startOperation();

    }

    }

    Hope this helps you.

    Thanks,

    Chaitanya Golla

  • faiz7049 Profile Picture
    2,430 on at

    Yes, i want this but custInvoiceJour.Field= inputValue not storing data.

  • faiz7049 Profile Picture
    2,430 on at

    custInvoiceJour.jpg

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 4 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans