Hi all.
I'm preparing a dataport to import sales order information from another system.
On the dataport import for the sales lines, I am validating the item no. (in the OnAfterImportRecord area) but when I do this, I lose the unit price information.
Can anyone advise on how I can validate the item number without losing the unit price information?
Thanks.
0
Comments
If you bring the price into a variable and then assign the variable to the unit price after the validation of the item it should work, so as an example:
VALIDATE (Type, Type::Item);
VALIDATE ("No.",ItemVarable);
VALIDATE (Quantity, QtyVariable);
"Sales Line"."Unit Price":=PriceVariable;
VALIDATE ("Sales Line"."Unit Price");
"Sales Line"."Unit Cost (LCY)":=CostVariable;
VALIDATE ("Sales Line"."Unit Cost (LCY)");
I believe this worked for me.
1. Use the field validate property on the data port fields
This requires that your data file list the fields in the order they need to be validated in.
2. Import the price to a variable. Then assign it to the sales line after you validate the item no.
Note you can either use the CallFieldCalidate Boolean in the Field Designer of the Dataport insteasd of putting it on the trigger.
Or better yet - Import all your data into Variables then you can map them to it's proper matching NAV field in the order that you want.
This way you have total control of what gets imported & when and you have more control of the validation process.
ex./
Lets say I have 3 variables i created in View->Golbals
v_Imported_No
v_Imported_Qty
v_Imported_Price
I enter these fields in the View->Dataport Fields instead of using the lookup directly to the Navision Standard Fields. Once the import begind the info is now saved in these variables. now on the OnAfterImportRecord I can bring them in the order that I want.
"Sales Line"."No." := v_Imported_No;
"Sales Line".VALIDATE("No."); //Get this out of the way!!!!!!
"Sales Line".Quantity := v_Imported_Qty;
"Sales Line".VALIDATE(Quantity); //Have control of validation
"Sales Line"."Unit Price" := v_Imported_Price; //put in the price at end to avoid changing
this is the proper way
VALIDATE ("No.",ItemVarable);
but i wanted to lay it out in an easy to understand manner
http://www.BiloBeauty.com
http://www.autismspeaks.org
Spent too much time on my pretty colors
http://www.BiloBeauty.com
http://www.autismspeaks.org
Thanks very much for the help!! I think I'll be using the variables approach. I find that the field validate property is kind of flaky, and doesn't always work. Has anybody else found that?