AL icon indicating copy to clipboard operation
AL copied to clipboard

WordManagement event issue

Open peterz84 opened this issue 8 years ago • 2 comments

I see the events OnAddFieldsToMergeSource and OnCreateHeaderAddFields were added in NAV2018 in #742 , but they are unusable because the WordMergeFile variable is used to add fields, but not available in the event Publishers.

I understand we don't want these .net variables in the events, so possibly a little redesign: first fill a temporary table with the field values you want to add to the mergefile and use this temporary table in the event Publisher, so partners can add there values to this table (TempTable=VAR).

So something like:

[External] AddFieldsToMergeSource(VAR WordMergefile ..........
.....
WITH WordFieldTable DO BEGIN <------ addfields to the temporary table
   AddField(Contact."No.");
   AddField(Contact."Company Name");
   AddField(Contact.Name);
   ...........
   OnAddFieldsToMergeSource(WordFieldTable,Salesperson,Country,Contact,CompanyInfo,SegLine,InteractLogEntry); <---- partners can add their values
   AddField(FaxMailToValue); <------ this value must come last and isn't now!
END;

WordFieldTable.FINDSET(FALSE,FALSE);
REPEAT
   WordMergeFile.AddField(WordFieldTable.Value);  <------ values are added to the WordMergeFile
UNTIL WordFieldTable.NEXT = 0;
WriteLine;

Add an AddField function to fill the WordFieldTable.

Also do this for OnCreateHeaderAddFields. Please make sure the event publishers are on their relative same position in their own functions, because they are not right now.

If adding this new temporary table is unwanted, you might want to consider using an array (Variant?) with a number of dimensions equalling the limit of adding fields to .net variable wordmergefile (there is a limit of around 64 I think). Even better would be to eliminate this limit of 64 fields, but that's a bigger change (for example not using WordMergeFile, but a real file or big text)

peterz84 avatar Dec 06 '17 15:12 peterz84

well there is a rather easy possibility to switch from HTML table to CSV tables. search for the blogspace using the search engine of your trust.

I did the stuff provided in the blog entry for NAV5 and I do know that it works for NAV2013+; It is an excel limitation, but only when using HTML tables. -.-

dennisroczek avatar Dec 09 '17 01:12 dennisroczek

About that: https://blogs.msdn.microsoft.com/freddyk/2009/09/20/word-management/

peterz84 avatar Dec 11 '17 13:12 peterz84