Stylesheet with barcode

PeterVersteegePeterVersteege Member Posts: 13
Using Dynamics NAV 2009, we try to create stylesheet which should contain a field which is from type 'Text' but is used to store barcode fields.
We added the merge field on the stylesheet, and set the font type to the barcode font.

But when we merge the document, the result is incorrect, because the mailmerge function cannot handle the "<<" and ">>" texts which are part of the mergefield definition on the styleheet (mergefield = <<Barcode>>). The result shows a field in barcode font, but in fact it doesnot show the value of the barcode-field, but it shows the caption 'Barcode'.

Did anyone experience this before, and knows a solution ?
K3 Business Solutions

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I have faced this before. I solved it by adding some code in codeunit 403, function LaunchApp, which performs some kind of search & replace function in the generated XML to replace the Barcode-field with the correct value. It's a dirty hack but it gets the job done.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • PeterVersteegePeterVersteege Member Posts: 13
    Thanks Luc for your response, I will try it this way.

    But in fact I was hoping for another answer, because we are using the mailmerge as part of a webservice. Creating an extra step in this process is not really what I am looking for, certainly because in my opinion this is a problem which should be solved in a hotfix. I think I am going to report this to Microsoft, and hopefully it will be solved in the nearby future...
    K3 Business Solutions
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I got a request to publish this dirty hack, so here it is:

    In Codeunit 403, function LauchApp:
    [...]
    
    lblnBarcodeTagExists := FALSE;
    lautXMLDomNodeList := DataXML.getElementsByTagName('Barcode');
    IF NOT(ISCLEAR(lautXMLDomNodeList)) THEN BEGIN
      FOR i := 1 TO lautXMLDomNodeList.length DO BEGIN
        lautXMLDomNodeList.item(i-1).text := lcodBarcodeValue;
        lblnBarcodeTagExists := TRUE;
      END;
    END;
    
    TransformDocument(DataXML,StylesheetXML,ApplicationXML);
    
    IF lblnBarcodeTagExists THEN BEGIN
      lautXMLDomNodeList := ApplicationXML.getElementsByTagName('w:t');
      IF NOT(ISCLEAR(lautXMLDomNodeList)) THEN BEGIN
        FOR i := 1 TO lautXMLDomNodeList.length DO BEGIN
          IF STRPOS(lautXMLDomNodeList.item(i-1).text,'_Barcode') > 0 THEN BEGIN
            lautXMLDomNodeList.item(i-2).text := '';
            lautXMLDomNodeList.item(i-1).text := lcodBarcodeValue;
            lautXMLDomNodeList.item(i).text := '';
          END;
        END;
      END;
    END;
    
    [...]
    
    EXIT(TRUE);
    
    Disclaimer: this hack works for me, but it might not work for you. This code is released without support.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.