Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Setting value in data source bound form control

(0) ShareShare
ReportReport
Posted on by 6

Hi there,

I want to change value of a form control based on selection on another form control. Please check the code snippet. Values are fetched, just doesn't pass into the control or gets displayed. Please note, controls are bounded to a Table DS.

public boolean modified()

boolean ret;

CustName cust;

str projinvoiceid;

projinvoiceid = AutoMakLoanHeader_ProjInvoiceProjId.text();
cust = ProjTable::findbyprojinvoice(projinvoiceid).custName();

//AutoMakLoanHeader_CustName.text("TEST");
AutoMakLoanHeader_CustName.text(cust);
AutoMakLoanHeader_CustAccount.text(ProjTable::findbyprojinvoice(projinvoiceid).CustAccount);
element.redraw();

ret = super();

return ret;
}

*This post is locked for comments

  • Verified answer
    Martin Dráb Profile Picture
    234,615 Most Valuable Professional on at
    RE: Setting value in data source bound form control

    No, trying to put directly to controls is of no use, if they have a source of data. You must change the source, which is then displayed in all controls bound to the the source.

    Note that changing the form datasource object isn't the same thing as saving it to database. That's done by write(), usually when you're leaving the record.

  • NoobDaxCoder Profile Picture
    6 on at
    RE: Setting value in data source bound form control

    Well, I dont value to be writern to DS until Save and Close button is clicked. Without writing to DS, can i not just display values in controls, and insert it into DS later. Like this

    vvoid clicked()

    {

       CustName                custName;

       CustAccount             custAccount;

       LoanType                loanType;

       Amount                  dealAmount;

       DueDate                 effectiveDate;

       YearBase                dealPeriod;

       Amount                  profit;

       CompanyBankAccountId    autoMakBankId;

       super();

       custName = AutoMakLoanHeader_CustName.text();

       custAccount = AutoMakLoanHeader_CustAccount.text();

       loanType    =AutoMakLoanHeader_LoanType.comboType();

       dealAmount = AutoMakLoanHeader_DealAmount.realValue();

       dealPeriod = AutoMakLoanHeader_DealPeriod.value();

       profit  = AutoMakLoanHeader_ProfitRate.realValue();

       autoMakBankId =  AutoMakLoanHeader_AutoMakBankId.text();

       AutoMakLoanHeader.CustName = custName;

       AutoMakLoanHeader.CustAccount = custAccount;

       AutoMakLoanHeader.LoanType     = loanType;

       AutoMakLoanHeader.DealAmount   = dealAmount;

       AutoMakLoanHeader.EffectiveDueDate = effectiveDate;

       AutoMakLoanHeader.ProfitRate        = profit;

       AutoMakLoanHeader.AutoMakBankId     = autoMakBankId;

    }

  • Suggested answer
    Martin Dráb Profile Picture
    234,615 Most Valuable Professional on at
    RE: Setting value in data source bound form control

    If you work with controls bound to a datasource, you shouldn't read and write values from and to individuasl form controls - you should use the underlying datasource itself. If your datasource is called AutoMakLoanHeader, there is a variable of the same and you get the value of ProjInvoiceProjId field by AutoMakLoanHeader.ProjInvoiceProjId and set the value of CustAccount field by an assignment to AutoMakLoanHeader.CustAccount (e.g. AutoMakLoanHeader.CustAccount = "TEST").

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Kempeth Profile Picture

Kempeth 4

#1
Andy Adamak Profile Picture

Andy Adamak 4

#1
Community Member Profile Picture

Community Member 4

Featured topics

Product updates

Dynamics 365 release plans