I have a Report in Microsoft Dynamics for printing customized labels.
The Report itself has one DataItem from the Items table. If you run the report, you can type in a item number and it prints a label on a selected thermo-printer.
Now, what i want to archive is, if i have an purchase order, i want to klick somwhere and navision should do something like this:
run report '50070' with item '10001' 6 copies of the label; run report '50070' with item '10020' 3 copies of the label;
and so on.
I didn't find quite much about this topic. I tried to do it with a copy loop as mentioned in some posts but that didn't quite work that way i wanted it.
Overview
Report DataItems:
"Item" -> Record::Item
The following code is from the Item - OnAfterGetRecord() - Trigger
RecordNo := RecordNo + 1;
ColumnNo := ColumnNo + 1;
ItData[ColumnNo][1] := FORMAT("No.");
ItData[ColumnNo][2] := FORMAT(Description);
ItData[ColumnNo][3] := FORMAT(Var1);
ItData[ColumnNo][4] := FORMAT(Var2);
ItData[ColumnNo][5] := FORMAT("Unit Price");
ItData[ColumnNo][5] := FORMAT("Unit Price" * 1.19);
// finding own barcode first, if no own barcode found, take
// the one you can get
barcodeStr := '';
recBarcode.SETFILTER("Item No.", "No.");
recBarcode.SETFILTER("Barcode No.", '99916*');
IF recBarcode.FINDFIRST THEN BEGIN
barcodeStr := recBarcode."Barcode No.";
END ELSE BEGIN
recBarcode.RESET;
recBarcode.SETRANGE("Item No.", "No.");
IF recBarcode.FINDFIRST THEN BEGIN
barcodeStr := recBarcode."Barcode No.";
END;
END;
// ask user, if to printing barcode is not a company own
// barcode, and let him decide if he whishes to print anyway
IF STRLEN(barcodeStr) = 13 THEN BEGIN
IF (COPYSTR(barcodeStr, 1, 5) <> '99916') THEN BEGIN
IF NOT CONFIRM('This item has NO company own barcode. Do you whish to print it anyway?', FALSE) THEN
EXIT;
END;
// format the barcode-string to a format, that the barcode font
// can understand and printing it properly for reading with a scanner
EAN13 := DADA.GetPrintTextEAN13(barcodeStr);
END;
COMPRESSARRAY(ItData[ColumnNo]);
IF RecordNo = NoOfRecords THEN BEGIN
FOR i := ColumnNo + 1 TO NoOfColumns DO
CLEAR(Addr[i]);
ColumnNo := 0;
END ELSE BEGIN
IF ColumnNo = NoOfColumns THEN
ColumnNo := 0;
END;
// finding a suiting logo for the barcode, user can choose between none, dd or ex
IF intLogoOption = 2 THEN BEGIN
IF EXISTS ('N:\Labelprinting\dd\75x75\sw_for75x75.bmp') THEN
TT.BLOBImport(BLOBRef, 'N:\Labelprinting\dd\75x75\sw_for75x75.bmp', FALSE);
END ELSE IF intLogoOption = 3 THEN BEGIN
IF EXISTS ('N:\Labelprinting\ex\75x75\sw_for75x75.png') THEN
TT.BLOBImport(BLOBRef, 'N:\Labelprinting\ex\75x75\sw_for75x75.png', FALSE);
END;
CALCFIELDS(Item.Picture);
My goal is, that the user can click once and select a printer once, and all labels get printed properly
You should make a copy of your report with following dataitems:
Sales Header
--Sales Line
----Integer
------Item
Put your code to print one sticker into Integer
dataitem. It will be executed number of times.
Filter Sales Header
with number of your order. Link Sales Line
to sales header, so report will run through all your items.
Put following code on Sales line - OnAfterGetRecord
:
Integer.setrange("Number",1,"Sales Line"."Quantity");
Put item filtering into Integer - OnPreDataItem
Item.setrange("No.", "Sales Line"."Item No.");
It will launch sticker printing as many times as many items you have in your order for every line. This will also allow you to print stickers for bunch of orders.