Lookup field-Query

navfresher
Member Posts: 44
I have a field(,"Utilised Against Doc No") which has lookup.
requirement: That lookup leads to the posted invoices.Once i select any posted invoice,the correspoding vendor shipment no field should get updated on the on the same form.I have written the code on On Validate of the field "Utilised Against Doc No",but the code is not working.
Situation : But when i tried to copy the document number and paste it instead of using lookup,the code is working and the value is getting reflected in the other field.
What could be the reason?Is it correct to write the code on On validate of that field?
requirement: That lookup leads to the posted invoices.Once i select any posted invoice,the correspoding vendor shipment no field should get updated on the on the same form.I have written the code on On Validate of the field "Utilised Against Doc No",but the code is not working.
Situation : But when i tried to copy the document number and paste it instead of using lookup,the code is working and the value is getting reflected in the other field.
purchInvheader.SETRANGE(purchInvheader."No.","Utilised Against Doc No"); IF purchInvheader.FINDFIRST THEN BEGIN PurchReciptHeader.SETRANGE(PurchReciptHeader."Order No.",purchInvheader."Order No."); IF PurchReciptHeader.FINDFIRST THEN "Vendor Shipment No.":=PurchReciptHeader."Vendor Shipment No."; END;
What could be the reason?Is it correct to write the code on On validate of that field?
0
Answers
-
Your code is in the correct place and look to be written correctly at first glance. Try this:
purchInvheader.SETRANGE(purchInvheader."No.","Utilised Against Doc No"); IF purchInvheader.FINDFIRST THEN BEGIN IF NOT CONFIRM('Found the Invoice Header.\Look for receipt with order no %1 ?', FALSE, purchInvHeader."Order No.") THEN EXIT; PurchReciptHeader.SETRANGE(PurchReciptHeader."Order No.",purchInvheader."Order No."); IF PurchReciptHeader.FINDFIRST THEN BEGIN IF NOT CONFIRM('Found the Receipt Header. Continue?') THEN EXIT; "Vendor Shipment No.":=PurchReciptHeader."Vendor Shipment No."; END; END;
You can also step through the debugger.0 -
Hi matttrax,
I have used the debugger and came to know that the code is not running at all.Why it is not running?Why the field is not getting validated even after selecting the document number?
Any reasons?What could be the problem?0 -
Do you have any code in the OnLookup trigger of the Utilised Against Doc No field?0
-
Ah, I misunderstood.
Are you using the default lookup functionality (just setting the TableRelation property on the field) or have you created custom lookup code in the OnLookup trigger for that field?0 -
matttrax wrote:Ah, I misunderstood.
Are you using the default lookup functionality (just setting the TableRelation property on the field) or have you created custom lookup code in the OnLookup trigger for that field?
I am using the default lookup functionality(By setting the TableRelation property)...0 -
I have found the solution for my problem...
The field has some table realation defined as well and the same was written as code on the lookup of the field...That was the reason....
Now i have removed the table relation and have written the code on the lookup of that field and its working fine...0 -
So indeed there was code on the OnLookup trigger.0
-
lvanvugt wrote:So indeed there was code on the OnLookup trigger.
yes,i have checked it after looking at your reply....Thank you...0 -
I have written the below code on Onlookup of a field after the lookup code of that field.This code is working fine.But the lookup code which was written over there is working only for the first line.When i am trying to enter the values in the second line of the form,the Lookup code is not working.
is there anythng on this code which can stop the lookup code not work for the second time?purchInvheader.RESET; purchInvheader.SETRANGE(purchInvheader."No.","Utilised Against Doc No"); IF purchInvheader.FINDFIRST THEN BEGIN PurchReciptHeader.RESET; PurchReciptHeader.SETRANGE(PurchReciptHeader."Order No.",purchInvheader."Order No."); IF PurchReciptHeader.FINDFIRST THEN "Vendor Shipment No.":=PurchReciptHeader."Vendor Shipment No."; END;
Any suggestions?0 -
One reason is that the value of "Utilised Against Doc No" causes
purchInvheader.SETRANGE(purchInvheader."No.","Utilised Against Doc No");
to filter-out all records.
What is the value of "Utilised Against Doc No" of the second line?
If that is not the issue then maybe purchInvheader."Order No." applied as a filter to PurchReciptHeader leads to no records.0 -
kapamarou wrote:One reason is that the value of "Utilised Against Doc No" causes purchInvheader.SETRANGE(purchInvheader."No.","Utilised Against Doc No"); to filter-out all records.
What is the value of "Utilised Against Doc No" of the second line?
If that is not the issue then maybe purchInvheader."Order No." applied as a filter to PurchReciptHeader leads to no records.
The value of "Utilised Against Doc No" is just a lookup field to select the Posted purchase invoice document no
If PurchReciptHeader leads to no records then the field which has to get updated should be empty,but the lookup field itself is not working,i,e it is just showing empty form.
The code which i have posted in the previous post is to update another field on the same form .It is not written for the lookup.0 -
Why are you creating a new thread when we have been discussing this issue alreade here: http://www.mibuso.com/forum/viewtopic.php?f=23&t=39293&p=192116#p192116?
The code should not be in the OnLookup trigger!0 -
lvanvugt wrote:Why are you creating a new thread when we have been discussing this issue alreade here: http://www.mibuso.com/forum/viewtopic.php?f=23&t=39293&p=192116#p192116?
The code should not be in the OnLookup trigger!
Then where am i supposed to write the code?0 -
The code you have written can been seen as business logic that is based on the validation of a valuie entered in the Utilised Against Doc No field. So this is code to be put in the OnValidate trigger of that field. I seem to recall from the other thread that there is where you had put it already.0
-
[Merged another topic into this topic]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
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
- 322 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