Release button logic

siimsand
Member Posts: 28
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?
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?
0
Best Answer
-
That is what your code requests. I don't know that Vendor Purchase Contract table, so I can't tell if it is supposed to be that way. But it would seem not very practical to me that a vendor can only have one contract so I would expect a table like that to have a compound key.5
Answers
-
what is the primary key of VendorPurchaseContract table?
why do you need 2 GET statements?0 -
mohana_cse06 wrote: »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>.0 -
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.0 -
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."?0 -
That is what your code requests. I don't know that Vendor Purchase Contract table, so I can't tell if it is supposed to be that way. But it would seem not very practical to me that a vendor can only have one contract so I would expect a table like that to have a compound key.5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions