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 :
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

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    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").

  • NoobDaxCoder Profile Picture
    6 on at

    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;

    }

  • Verified answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    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.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans