You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method AddUnrelatedTable from the Word Template codeunit has the following 2 issues, which I don't believe are by design:
The method does not return the result from the implementation codeunit. This results in callers always thinking that the method failed to add the record in the table.
In the implementation, the specified WordTemplateCode does not actually get set on the new "Word Templates Related Table" record. This results in the related table being unusable in the Word Template.
Expected behavior
The method should return true if the record was added; otherwise, false. (which would match the method documentation)
The created "Word Template Related Table" record should contain the Word Template Code that was given to the method.
Steps to reproduce
The following code demonstrates the issue and is reproducible. This will only work in the context of a Microsoft App since the problematic table is internal. One can use recordrefs to observe the same result.
local procedure IssueRepro()
var
WordTemplateRec: Record "Word Template";
CompanyInformation: Record "Company Information";
WordTemplatesRelatedTable: Record "Word Templates Related Table"; // (Access = Internal)
WordTemplate: Codeunit "Word Template";
Result: Boolean;
MyTemplateCodeLbl: Label 'MY TEMPLATE', Locked = true;
MyTemplateNameLbl: Label 'My Template', Locked = true;
begin
WordTemplateRec.Init();
WordTemplateRec.Code := MyTemplateCodeLbl;
WordTemplateRec.Name := MyTemplateNameLbl;
WordTemplateRec."Table ID" := Database::Microsoft.Sales.Customer.Customer;
WordTemplateRec.Insert(true);
CompanyInformation.Get();
Result := WordTemplate.AddUnrelatedTable(WordTemplateRec.Code, 'COMPA', Database::"Company Information", CompanyInformation.SystemId);
// Result should be true, but the method always returns false
WordTemplatesRelatedTable.Get(WordTemplateRec.Code, Database::"Company Information");
// This call will currently always fail because the Code is empty on the created record.
// This *could* be by design, but I have a hard time believing that. As is, the created record
// is never usable by the word template (nor does it appear in the UI since Code is empty).
end;
Additional context
Further evidence that this behavior is not part of the original design is that in the initial check for IsRelatedTableCodeAndIdUnique, the WordTemplateCode is used as a filter on the Code field.
I will provide a fix for a bug
I will provide a fix for a bug
The text was updated successfully, but these errors were encountered:
Describe the issue
The method
AddUnrelatedTable
from theWord Template
codeunit has the following 2 issues, which I don't believe are by design:Expected behavior
Steps to reproduce
The following code demonstrates the issue and is reproducible. This will only work in the context of a Microsoft App since the problematic table is internal. One can use recordrefs to observe the same result.
Additional context
Further evidence that this behavior is not part of the original design is that in the initial check for
IsRelatedTableCodeAndIdUnique
, theWordTemplateCode
is used as a filter on theCode
field.I will provide a fix for a bug
The text was updated successfully, but these errors were encountered: