Release button logic

Hello!

I have this code under the Release action button:

Release - OnAction()
IF PurchaseHeader.GET("Document Type","No.") THEN BEGIN
PurchaseHeader.TESTFIELD("Purchase Contract"); //checks if the purchase contract field is filled
PurchaseHeader.TESTFIELD("Posting Date"); //checks if the posting date field is filled
VendorPurchaseContract.GET(PurchaseHeader."Buy-from Vendor No.");
VendorPurchaseContract.GET();
VendorPurchaseContract.TESTFIELD("Begin Date"); //need these 2 to be filled for the next if sentence
VendorPurchaseContract.TESTFIELD("End Date");
//PurchaseHeader.SETFILTER("Posting Date",'%1..%2', VendorPurchaseContract."Begin Date",VendorPurchaseContract."End Date");
IF (PurchaseHeader."Posting Date" >= VendorPurchaseContract."Begin Date") AND //check if posting date between
(PurchaseHeader."Posting Date" <= VendorPurchaseContract."End Date") THEN BEGIN
VendorPurchaseContract.TESTFIELD(Sum); //checks if the Sum field is filled
IF (PurchaseHeader."Amount Including VAT" <= VendorPurchaseContract.Sum) THEN //no release before the final condition is met
ReleasePurchDoc.PerformManualRelease(Rec);
END;
END;

Debugger shows that the line VendorPurchaseContract is '', but actually I have 6 records/lines for that. Anyone know what the problem could be?

Best Answer

Answers

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    what is the primary key of VendorPurchaseContract table?
    why do you need 2 GET statements?
  • siimsandsiimsand Member Posts: 28
    edited 2018-01-25
    what is the primary key of VendorPurchaseContract table?
    why do you need 2 GET statements?

    The primary key is "Vendor No." for that table. Because I've come to the understanding that I need the "Buy-from Vendor No." from PurchaseHeader and the "Vendor No." from VendorPurchaseContract table to read in the data. Also, the error message I get is that "The entry for VendorPurchaseContract does not exist. Fields and values: Buy-from Vendor No. = '<current Buy-from Vendor No.>' " It seems that the VendorPurchaseContract record is <Uninitialized>.
  • AKAK Member Posts: 226
    I suppose the debugger stops at
    VendorPurchaseContract.GET(PurchaseHeader."Buy-from Vendor No.");
    
    which means that there is no record in the table that has a primary key that matches the "Buy-from Vendor No.".
    Manually filter the primary key field with the vendor number and you will not see a record.
  • siimsandsiimsand Member Posts: 28
    AK wrote: »
    I suppose the debugger stops at
    VendorPurchaseContract.GET(PurchaseHeader."Buy-from Vendor No.");
    
    which means that there is no record in the table that has a primary key that matches the "Buy-from Vendor No.".
    Manually filter the primary key field with the vendor number and you will not see a record.

    Yes, that's where I'm confused. So the record in VendorPurchaseContract."Vendor No." should be valued with/equal to PurchaseHeader."Buy-from Vendor No."?
Sign In or Register to comment.