Monday, February 22, 2021

NAV / BC AL - How to insert records easily

 procedure ICHInsertICHLine(var Parent: code[20]; Cat: code[20]; Itm: code[30]; Desc: text[100]; Ind: Integer)

    var
        ICH: Record "Item Category Hierarchy";
    begin
        ICH.reset; //make sure it's clean
        ICH.Init(); //Start fresh line
        ich.Validate("Parent Category", Parent); //Set all the key fields first
        ich.Validate(code, Cat); //Set all the key fields first
        ich.Validate(ItemNo, Itm); //Set all the key fields first
        ICH.Insert; //Insert those
        ich.Validate(Description, Desc); //Finish off all the others
        ich.Validate(Indentation, Ind); //Finish off all the others
        ich.Modify(TRUE); //Modify the final record

    end;

No comments:

Post a Comment