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 :
Finance | Project Operations, Human Resources, ...
Answered

Initialize CustAccount in SalesCreateOrder form

(0) ShareShare
ReportReport
Posted on by 8
Hello,
I have a requirement to add a button on a custom form which will open the SalesCreateOrder form (to create a new sales order).
There is a custom customer account (TSTCustAccount) setup in CustParameters which the form needs to automatically initialize with.
I have added a new boolean parm method in the class extension of SalesTableForm.
I have added a new button in my custom form and added the following codes in the clicked method :
 
SalesTableForm salesTableForm = SalesTableForm::construct(SalesTableFormId::None, null);
salesTableForm.tstParmTest(true);
salesTableForm.create();
 
I have then added a logic in the post init of the SalesCreateOrder form extension:
 
if (salesTableForm.tstParmTest())
        {
            CustParameters tstCustParameters = CustParameters::find();
 
            if (tstCustParameters.TSTCustAccount)
            {
                SalesTable.CustAccount(tstCustParameters.TSTCustAccount);
                SalesTable.modifiedField(fieldNum(SalesTable, CustAccount));
            }

        }
 
However, the customer account field is still empty.
I have tried doing in the SalesTable_DS.initValue, but it is still empty.
Is there another way to do this particular requirement?
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    238,759 Most Valuable Professional on at
    init() method of a form just initialized form controls, data source objects etc., but no data is loaded and no new record is created at the moment. That happens later, when the form is actually executed.
     
    A good method for your purpose is initValue() and the data source, which is called when a new record is being created. But don't extend it; instead, look at what code it already contains. It calls initValues() of SalesTableForm, but we won't extend that either. We can see that this method takes the value of CustAccount from custAccount(), which is a parameter method.
     
    When we look at where the custAccount value is used, we'll find that we can simply pass it to create() method:
    SalesTableForm salesTableForm = SalesTableForm::construct(SalesTableFormId::None, null);
    salesTableForm.create(CustParameters::find().TSTCustAccount);
  • Verified answer
    Jason0810M Profile Picture
    8 on at
    Hello Martin,
    I have tried it and it did not work.
    I have tried another approach and it seems to work fine.
     
    CustParameters tstCustParameters = CustParameters::find();
    SalesTableForm salesTableForm = SalesTableForm::construct(SalesTableFormId::None, null);
    salesTableForm.tstParmTest(true);
    salesTableForm.custAccount(CustParameters.TSTCustAccount);
    salesTableForm.create();
     
    I have added an override of the SalesTableForm.initValues() as follows.
     
    next initValues();
    if (this.tstParmTest() && SalesTable.CustAccount)
    {
    //call logic to initialise standard fields as per customer selected
        SalesTable.modifiedField(fieldNum(SalesTable, CustAccount));
    }

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans