Search code examples
axaptadynamics-ax-2012x++

AX2012 - Get new primary table field value by creation


i have a form with two grids. Each grid has it own datasource. For more information look at the attached picture.

On dependence which line i select in the first grid, the content of the second grid will change.

Now my problem: If i create a new row on the first grid, i am not able to enter values in the second grid because ax don't give me a new "combinationID" (Primary field, INT)

enter image description here

How can i solve this?


Solution

  • This looks like a parent-child form where the upper grid is your "header" and the lower is your "lines".

    If CombinationID is your primary key, it should probably be generated via number sequence or unique somehow.

    On the form, the DataSource MDISSearchDimensions's property JoinSource should be set to MDISAccountSearchTerms. It will use the table relation, but you need to specify they're joined.

    Then once your CombinationID is set from the header, you just need to make sure the lines get it. On the table MDISSearchDimensions, add a method called initFromMDISAccountSearchTerms(MDISAccountSearchTerms _MDISAccountSearchTerms), which sets the CombinationID and call this method inside MDISSearchDimensions.initValue().