Installation guide

Zetadocs for NAV Installation Guide
This edition 5
th
December 2012 © Copyright Equisys plc 2012 All trademarks acknowledged All rights
reserved
Page 74
PROCEDURE GetAutoLink@1000000006(ZdArchiveContext@1000000002 : Record 9009992;VAR
ZdLinkResult@1000000001 : Record 9009997;ZdControlFile@1000000000 : Text[250];VAR
ZdDocQueueBarcodes@1000000003 : Record 9009995);
VAR
msgNoBarcodes@1000000005 : TextConst 'DAN=Auto linking failed. No barcodes were detected on the
document.;DEU=Auto linking failed. No barcodes were detected on the document.;ENU=Auto linking failed. No barcodes
were detected on the document.;ESP=Auto linking failed. No barcodes were detected on the document.;FRA=Auto linking
failed. No barcodes were detected on the document.;ITA=Auto linking failed. No barcodes were detected on the
document.;NLD=Auto linking failed. No barcodes were detected on the document.;ENG=Auto linking failed. No barcodes
were detected on the document.';
msgCouldNotFindRecord@1000000006 : TextConst 'DAN=Auto linking failed. Could not find record matching barcode:
%1;DEU=Auto linking failed. Could not find record matching barcode: %1;ENU=Auto linking failed. Could not find record
matching barcode: %1;ESP=Auto linking failed. Could not find record matching barcode: %1;FRA=Auto linking failed.
Could not find record matching barcode: %1;ITA=Auto linking failed. Could not find record matching barcode:
%1;NLD=Auto linking failed. Could not find record matching barcode: %1;ENG=Auto linking failed. Could not find record
matching barcode: %1';
barcodeVal@1000000004 : Text[80];
ShipmentRec@1000000007 : Record 110;
RecRef@1000000008 : RecordRef;
BEGIN
ZdUtilities.Log(0, 'C9009964 - AutoLink');
This code should be the same for every report and doesn’t need repeating with each if statement.
// Use the barcodes that are passed in to find the record to link to.
// Call reset to clear any filters that may be on the barcodes temporary table
ZdDocQueueBarcodes.RESET;
IF NOT ZdDocQueueBarcodes.FIND('-') THEN
BEGIN
// There are no barcodes so don't modify the record.
// Processing will fall back to calling the Link function for the manual method.
EXIT;
END;
barcodeVal := ZdDocQueueBarcodes.Value;
IF Statement
// If the barcode starts with SHIP it means it is a shipment note.
// The barcode will be in the format SHIP000000, where 000000 is the shipment number
IF (STRLEN(barcodeVal) > 4) AND (COPYSTR(barcodeVal, 1, 4) = 'SHIP') THEN
BEGIN
ShipmentRec.RESET;
ShipmentRec."No." := COPYSTR(barcodeVal, 5);
// If we can find the record that the barcode refers to
IF ShipmentRec.FIND THEN
BEGIN
// if the user selected a record use a RecordRef to get the RecordID for the record
// and modify the ZdLinkResult record to include it
RecRef.GETTABLE(ShipmentRec);
ZdLinkResult."Record ID" := RecRef.RECORDID;
ZdLinkResult.MODIFY;
END;
END;
EXIT;
END;