![]() |
#1 |
Участник
|
For those that have not used this before, the Style Sheet Tool is a free code sample used as an addition to standard Dynamics NAV application, for enhancing send-to Word functionality on Dynamics NAV by allowing simple and user-friendly style sheet customization.
After lots of feedback form partners, we have added an extra dimension to this tool: the ability to export several tables with multiple records. Up to now, any number of tables was allowed provided they all show one record each, in addition to one table showing multiple records. This ’constraint’ is now removed, or rather, the design is adjusted to allow several tables showing multiple records each, to be included in merge document design. To align the tool with this extension, the following code needs to be replaced: Codeunit 680 : Style Sheet Management Global variables: add NoOfMultiLineTables and MLCounter Name DataType Subtype Length XMLDoc Automation 'Microsoft XML, v4.0'.DOMDocument40 MailMergeXMLDoc Automation 'Microsoft XML, v4.0'.DOMDocument40 AttributeArray Text 250 GroupElement Text 250 StyleSheetTemplateCode Code 20 StyleSheetFunctions Codeunit Style Sheet Functions Status Dialog InMultiLineSection Boolean NoOfMultiLineTables Integer MLCounter Integer ManageMultiLineChanges trigger Old Code: ... RemoveEndOfMultiLine(NodeTextValue); EXIT(Return); ... New Code: ... RemoveEndOfMultiLine(NodeTextValue); // EXIT(Return); //changed line ... CreateMultilLineSection trigger Old Code: // Create section for Multi-Lines ChildNode := IOChildNode.parentNode; ... New Code: // Counter for multiple multiline sections //added line MLCounter +=1; //added line // Create section for Multi-Lines ChildNode := IOChildNode.parentNode; ... CreateMultiLineBody trigger Local variables: the following local variable is added to the trigger Name DataType MultilineEnd Boolean Old Code: ... ParentNode := ChildNode.parentNode; LoadAttributes(1,'name','multiline-section-properties'); AddElement(ParentNode,NewChildNode,Text043,1); ... New Code: ... ParentNode := ChildNode.parentNode; // Add counter to multiline section name, for unique reference // added line LoadAttributes(1,'name','multiline-section-properties'+FORMAT(MLCounter)); //changed line AddElement(ParentNode,NewChildNode,Text043,1); ... Old Code: ... ChildNodeList := ParentNode.childNodes; FOR NodeCount := 1 TO ChildNodeList.length DO BEGIN ChildNode := ChildNodeList.item(NodeCount - 1); TempNodeName := ChildNode.nodeName; IF TempNodeName = Text043 THEN MultiLineNodeCount[1] := NodeCount; TempNodeValue := GetTextNodeValue(ChildNode); IF TempNodeValue <> '' THEN MultiLineNodeCount[2] := NodeCount - 1; END; // If MULTILINE_END is not found then set end to number of nodes. IF MultiLineNodeCount[2] = 0 THEN MultiLineNodeCount[2] := NodeCount; ... New Code: ... ChildNodeList := ParentNode.childNodes; NodeCount := 1; //added line WHILE (NodeCount <= ChildNodeList.length) AND (NOT MultilineEnd) DO BEGIN //changed line // exit the loop when next multiline end is found //added line ChildNode := ChildNodeList.item(NodeCount - 1); TempNodeName := ChildNode.nodeName; IF TempNodeName = Text043 THEN BEGIN //changed line MultiLineNodeCount[1] := NodeCount; END; TempNodeValue := GetTextNodeValue(ChildNode); IF TempNodeValue <> '' THEN BEGIN //changed line IF STRPOS(TempNodeValue,Text021) <> 0 THEN MultilineEnd := TRUE; //added line MultiLineNodeCount[2] := NodeCount - 1; END; //added line NodeCount +=1; //added line END; IF NodeCount <= ChildNodeList.length THEN NodeCount := NodeCount -1; //added line MultilineEnd := FALSE; //added line // If MULTILINE_END is not found then set end to number of nodes. IF MultiLineNodeCount[2] = 0 THEN MultiLineNodeCount[2] := NodeCount; ... RemoveEndOfMultiline Trigger Old Code: // Remove end node of Multi-Lines ChildNodeList := XMLDoc.getElementsByTagName('w:r'); FOR NodeCount := 1 TO ChildNodeList.length DO BEGIN ChildNode := ChildNodeList.item(NodeCount - 1); ParentNode := ChildNode.parentNode; IF STRPOS(GetTextNodeValue(ChildNode),Text021) <> 0 THEN BEGIN ParentNode.removeChild(ChildNode); EXIT; END; END; New Code: // Remove end node of Multi-Lines // nodetextvalue = multiline_begin_tablename NodeTextValue := COPYSTR(NodeTextValue,17,MAXSTRLEN(NodeTextValue)); //added line ChildNodeList := XMLDoc.getElementsByTagName('w:r'); FOR NodeCount := 1 TO ChildNodeList.length DO BEGIN ChildNode := ChildNodeList.item(NodeCount - 1); ParentNode := ChildNode.parentNode; IF STRPOS(GetTextNodeValue(ChildNode),Text021) <> 0 THEN BEGIN //Check if this is the right MULTILINE_END to remove // added line IF STRPOS(GetTextNodeValue(ChildNode),Text021+'_'+NodeTextValue) <>0 THEN //added line ParentNode.removeChild(ChildNode); // EXIT; // remove all ends //changed line END; END; The extended codeunit 680 object is also attached. Note: This extension works with both Style Sheet Tool 1.1 and Style Sheet Tool 2.0 You can direct your questions or feedback to jthunes@microsoft.com Источник: http://feedproxy.google.com/~r/Micro...-extended.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|