Search code examples
axaptax++dynamics-ax-2009

How can the value of the "Quantity" field in bill of material lines be copied to the field "Height" during data entry?


When editing bill of material (BOM) lines, the value of field "Quantity" should be copied to field "Height". How can this be achieved?

See also the following two pictures:

http://www.hostingpics.net/viewer.php?id=205252BOM1.jpg http://www.hostingpics.net/viewer.php?id=282509BOM2.jpg


Solution

  • Table you are looking for is called BOM.

    "Quantity" field is called BOMQty.

    "Height" field is called dim1.

    Both BOMQty and dim1 are of type real, so there should not be any real issues initializing the values. The main question is WHEN do you need to initialize "Height" field. For learning purposes, try playing with this code:

    BOM BOM; //Table buffer
    ttsBegin;
    while select forUpdate BOM
    {
        BOM.dim1 = BOM.BOMQty;
        BOM.update();       
    }
    ttsCommit;
    

    For just updating the field once, I would suggest using update_recordset

    For initializing the height upon line creation, add this line to BOM.insert() method, before calling super():

    this.dim1 = this.BOMQty;