Installation guide

Zetadocs for NAV Installation Guide
This edition 5
th
December 2012 © Copyright Equisys plc 2012 All trademarks acknowledged All rights
reserved
Page 84
Adjusting the PostArchive Function
Next we need to add some extra code into the PostArchive function to send the Purchase Approval for a
given item. Again this code needs to be pasted around the existing code.
PostArchive (…)
{
// Check if the archive was successful
IF NOT ( ZdArchiveResult."Archive Document" AND
ZdArchiveResult."Archive Succeeded") THEN
BEGIN
EXIT;
END;
// Check this is the purchase invoice document queue
IF ZdArchiveContext."Zetadocs Doc. Queue No." = 'ZDQ0020' THEN
BEGIN
// Use a RecordRef to get values from the record
IF NOT RecRef.GET(ZdArchiveResult."Record ID") THEN
BEGIN
// Could not get the record from the record id
EXIT;
END;
// Get a fieldref to the document type field
fRef := RecRef.FIELD(1);
// Store the value as an integer so that we can compare it
DocType := fRef.VALUE;
// Check we have linked to an order
IF (DocType <> PurchaseOrder."Document Type"::Order) THEN
BEGIN
// If it is not an order we cannot start approval, so exit
EXIT;
END;
// Get a fieldref to the No. field
fRef := RecRef.FIELD(3);
// Store the order no
OrderNo := fRef.VALUE;
// Set range of the purchase order record so only looking at
// orders
PurchaseOrder.SETRANGE( "Document Type",
PurchaseOrder."Document Type"::Order);
// Set range so only looking at this specific order
PurchaseOrder.SETRANGE("No.",OrderNo);
// Check that an order exists in the range
IF PurchaseOrder.FIND('-') THEN
BEGIN
// Call into approvals management codeunit to start the approval process
IF ApprovalsMgmt.SendPurchaseApprovalRequest(PurchaseOrder) THEN;
END;
END;