add new BOM via X++ code

alonfrialonfri Member Posts: 4
edited 2010-01-19 in Dynamics AX
Hello,

i want to add a new BOM, by X++ method, based on data i receive from the user by a form iv'e made.
what records do i need to add and to which table? (BOM, BOMTable, BOMVersion)
does the adding order makes any difference?

Thank you,

Alon.

Comments

  • MikerMiker Member Posts: 105
    hi, first of all, you should create record in InventTable with Bom type, than explore how works form BOMConsistOf on click button CreateBOM
    void clicked()
    {
        BOMId   fromId;
    
        super();
    
        if (BOMVersion)
            fromId = BOMVersion.BOMId;
    
        if (BOMVersion || ! BOMVersion.ItemId)
            BOMVersion_ds.create();
    
        BOMVersion.BOMId = BOMTable::promptCreateBOM(BOMVersion.ItemId,fromId);
        if (BOMVersion.BOMId)
        {
            if (BOMParameters::find().MandatoryQtyAndDate)
            {
                BOMVersion.FromDate = systemdateget();
                BOMVersion.ToDate   = systemdateget();
            }
            BOMVersion.Name = BOMTable::find(BOMVersion.BOMId).Name;
            BOMVersion_ds.write();
            BOMVersion_ds.refresh();
        }
        else
        {
            BOMVersion_ds.delete();
        }
        element.setBOMVersionApprove();
    }
    
    and only than create line/
    going to Europe
Sign In or Register to comment.