Now i've come across a C/AL code example on how to insert data through code using templates.
Now in that example first a customer (in my case item) is created and next a template is applied.
The code is as following:
// First insert a record Customer.INSERT(TRUE); // Apply a template RecRef.GETTABLE(Customer); ConfigTemplateMgt.UpdateRecord(ConfigTemplateHeader,RecRef); RecRef.SETTABLE(Customer); // Insert Dimensions – related templates MiniDimensionsTemplate.InsertDimensionsFromTemplates(ConfigTemplateHeader,Customer."No.",DATABASE::Customer);
Now creating an empty item is pretty straight forward but once created in don't get on how i should get the item to apply a template to it.
I assume in the code example RecRef is the newly created customer but i don't know for sure.
(Also a slightly important detail, i'm coding in AL so i'm trying to convert it to that just so that there aren't any misconceptions.)
Anyone knows the solution for that?
UPDATE:
So the code i have until now is following:
Item.Insert(true); ConfigTemplateHeader.SetRange("Table ID", 27); if ConfigTemplateHeader.FindFirst() then begin RecRef.SetTable(Item); ConfigTemplateMgt.UpdateRecord(ConfigTemplateHeader, RecRef);
Now again, I'm just guessing that RecRef (RecordRef) is supposed to be the record i last created but i actually doubt that that is the case. So now i can insert an empty item, get the template and the way i see it update the record with the last line of code but there still remains on how to get the created record.