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)

Insert A record from a Table into a Form

(0) ShareShare
ReportReport
Posted on by

I am trying to use a Insert Method on a table to default the values on two fields. The form is already linked to a productId, I am trying to use the productId to pickup the two fields that I need, but i cant find any code to use for this online. Anyone Can Help. The Table im Trying to use is RetailInventTable and pass the information in the EcoResProductVariantPerCompany Form. Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Does the productID field exist in the table where you want to default the fields?  If not, you will have to perform a lookup on the table where the productID field is and use that as criteria.  If it does, should be easy, just use if(this.productID){ do something }

  • Community Member Profile Picture
    on at

    The Table RetailInventTable has all the fields i am using. When I create the product; with the two fields, it get saved in the RetailInventTable. Then when I open the Released SKUs tab I want to the fields that are now associated with the ProductId to default on the two identical control. Im figuring I can use an INSERT in the RetailInventTable to send the data to the form or have a INIT on the button that will look automatically for the information. My problem is trying to see what the syntax of the code looks like. Im still relatively new to AX developement and cant find references of this kind of code that does from tables to Forms.

  • Suggested answer
    Community Member Profile Picture
    on at

    AX 2012?  I am not quite clear on this part "ProductId to default on the two identical control"

    If you have a table that you want to initialize some fields based upon other fields then what you need to do is following:

    insert() 
    {
       ;
       this.SomeField = this.SomeOtherField;


    }

  • Community Member Profile Picture
    on at

    Yeah this is all being done in AX 2012, I have a ProductId associated with new Product Master created. When i created that Product Master there is a record that is created and stored in the RetailInventTable; in this table are other fields that are associated with the products Booleans, time stamps etc. Two of those fields that are create I need to use again that will default onto a Form --> Released SKUs. When you open this form, it recognizes the ProductId, what i need is when it recognizes the productID to also see the two other fields that have been created previously and stored in the table RetailInventTable and have their Values default into two controls on the field.

    Could  I use the Insert method above to insert directly into a Form?

  • Verified answer
    Community Member Profile Picture
    on at

    What is the datasource for the Released SKUs form?  (Sorry, no access to 2012 currently).  If the datasource is a different table then RetainInventTable, you should write code in the forms datasource table to initialize the field based upon the RetainInventTable information.

    Pseudo code:

    insert() //this is on whatever table is the forms (released SKUs) datasource
    {
       RetailInventTable retailInventTable;
       ;
       select retailInventTable where retailInventTable.ProductId == this.ProductId;

       //we now have the retailInventTable information
       this.SomeField = retailInventTable.SomeField;
       this.SomeField2 = retailInventTable.SomeField2;

    }

    The insert() method will be called when you save a record in your form.  So you won't see this.SomeField initalized until after you save the record.  If you want to see the record right away when you open the form, override the initValue() method on the table (code would be the same)

  • Community Member Profile Picture
    on at

    Great thank you!!

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