Hello expert,
as the subject says I am trying to fill a new field in sales header with the item description of first sales line (in same sales order). Here is my code (which doesnt work
)
Please advice what I am missing
//CR -013+++
IF ("Line No." = 10000) THEN BEGIN
so.GET("Document Type"::Order,"Document No.");
IF so.FINDSET THEN BEGIN
so.Description := Item.Description;
so.MODIFY;
END;
END;
//CR -013---
"Description 2" := Item."Description 2";
Answers
Then you need to get the ItemRec before you can make the
"so.Description := Item.Description;"
The Code Could look like the following.
IF ("Line No." = 10000) AND (Type = Type::Item) THEN
IF (so.GET("Document Type","Document No.")) AND Item.get("No.") then begin
so.VALIDATE(Description,Item.Description);
so.MODIFY(TRUE);
END;
Edit:
I don´t like the filter on Line No 10000 - How can you be sure this is the first line of the order?
br
Hawkeye
My aim is to get the first line of sales line.
No. - OnValidate()
Hope this is the right place
Lookup("Sales Line".Description WHERE (Document Type=FIELD(Document Type),Document No.=FIELD(No.),Line No.=CONST(10000)))
but you need to put CurrForm.UPDATE after validating the Item No.
so you dont need any coding at all.
one question, if the user sorted Descending then what should happen.
any way, Try Max instead of Lookup and remove the Line No. filter.
And using MAX without LINE NO. filter is giving random result i.e. description of LINE NO. 80000 or 30000... cant find any pattern.cant we sort the salse line on basis on Line No & select the first/smallest LINE NO.?
Lookup("Sales Line".Description WHERE (Document Type=FIELD(Document Type),Document No.=FIELD(No.),Type=FILTER(item)))
thanks for your time & it was a great learning..