Dear folks, I want that, when a purchase invoice is registered and the VAT Prod. Posting Group field, from Purchaser line table, is VAT16, automatically it goes to a form that I’ve created.
I put the following code in the OnPush form the register button:
purchaseline.INIT;
IF purchaseline.GET("Buy-from Vendor No.") THEN;
IF purchaseline."VAT Prod. Posting Group"='VAT16' THEN
form1.RUN;
(The purchaseline var is the Purchase Line table, and the form1 var is the form that I want to show when VAT Prod. Posting Group field is VAT16)
But, when I register the invoice it shows me the message “The Code expression can’t turn to a Option value”.
Please, anybody knows how I can solve it?.
Many thanks in advance.
0
Answers
if you want to search for the Vendor No, you will have to use SetRange.
But this only works if the first purchase line is VAT16.
Tino Ruijs
Microsoft Dynamics NAV specialist
1) Because we are in the Attain forum, I assume that DarkHorse is using NAV 3.60 or 3.70 and it means that he can use just FIND('-') instead FINDFIRST
2) DarkHorse: never use the "magic constant" like you are using the "VAT16". Add new field into some setup table, where user can select this value, and use this field from the setup to compare it with the value from PurchaseLine...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thanks in advance.
Tino Ruijs
Microsoft Dynamics NAV specialist
Only the first purchase line is checked.
Maybe you want to run the form when one of the purchase lines has purchaseline."VAT Prod. Posting Group"='VAT16'?
Tino Ruijs
Microsoft Dynamics NAV specialist
It's curious because it seems that it look for because the process take a long time and, on the state line, you can see as it look for on the purchase line table, but finally it doesn't go to the form.
Tino Ruijs
Microsoft Dynamics NAV specialist
purchaseline.RESET;
purchaseline.SETRANGE("Document Type", "Document Type");
purchaseline.SETRANGE("Document No.", "No.");
purchaseline.SETRANGE("Buy-from Vendor No.", "Buy-from Vendor No.");
IF purchaseline.FIND('-') THEN BEGIN;
IF purchaseline."VAT Prod. Posting Group"='VAT16' THEN
form1.RUN;
END;
Or you could replace form1.RUN; by MESSAGE('TEST'); and see if you get the message.
By the way. When modifying a form you should close NAV and login again to make sure you test the correct form.
Or at least close the form you just modified. And put the Object Cache (KB) to 0 (Tools, options, Object Cache (KB)).
Tino Ruijs
Microsoft Dynamics NAV specialist
lineacompra.RESET;
lineacompra.SETRANGE("Document Type", "Document Type");
lineacompra.SETRANGE("Document No.", "No.");
lineacompra.SETRANGE("Buy-from Vendor No.", "Buy-from Vendor No.");
MESSAGE:='HELLO';
IF lineacompra.FIND('-') THEN BEGIN;
IF lineacompra."VAT Prod. Posting Group"='VAT16' THEN
formulario1.RUN;
END;
After that line the message doesn't show, it means that the rest of the lines doesn't work.
If so, you have to put the code in two OnPush-triggers. Better is then to create a function and call the function from both the OnPush-triggers.
Tino Ruijs
Microsoft Dynamics NAV specialist
If so, you have to put the code in two OnPush-triggers. Better is then to create a function and call the function from both the OnPush-triggers.
Tino Ruijs
Microsoft Dynamics NAV specialist
The form shows me during the register process and I want to show it at the final of it, it's not very important, I think it's just a few testings.
Thank you very much for help and your time.
If it works, it's fine!
Look out with modifying posting codeunits. The code you used now can't do much wrong, but be careful.
Have you checked if there were 2 buttons?
Tino Ruijs
Microsoft Dynamics NAV specialist
Thanks again for your esteemed help.
Ok. Strange. :-k
Can you put (SOLVED) in the title of the first post?
Tino Ruijs
Microsoft Dynamics NAV specialist