Hi, brothers!
thank you, i've managed to copy all the data to the new company.
Question?
want to run a report, but it should show data from an option data type chosen from request form.
i have a sales invoice line with field type of option data type.
whenever i run my report it should only print data from one of the selected option string(,g\l account,item,resource,item charge)
i have a request form with a textbox and its sourceexp = InputType
InputType is a global variable of option type
optionstring = ,g\l account,item,resource,item charge
here is sample of my code
sales invoice line onAfterGetRecord
IF InputType = "Sales Invoice Line".Type::Item THEN BEGIN
//counter:=COUNT;
TotalCost:="Unit Cost (LCY)" * Quantity;
Profit:="Line Amount" - TotalCost;
IF "Line Amount" <> 0 THEN
Margin:=Profit / "Line Amount" * 100
ELSE Margin :=0 ;
TTotalCost += TotalCost;
TotalSales += "Line Amount";
TotalProfit += Profit;
IF TotalSales <> 0 THEN
TotalMargin:=TotalProfit / TotalSales * 100
ELSE TotalMargin :=0 ;
GTotalCost += TTotalCost;
GTotalSales += TotalSales;
GTotalProfit := GTotalSales - GTotalCost;
IF GTotalSales <> 0 THEN
GTotalMargin:=GTotalProfit/GTotalSales * 100
ELSE
GTotalMargin := 0;
END;
Learning Never End.
0
Comments
It print nothing, did it? :shock:
As far as I saw from your codes, it only proceed if InputType = Item?
But you have many options under your InputType variable, such as: g\l account, resource, item charge.
Have you tried to make "item" to "Item", ensure that this is not case sensitive problem?
And ensure that you have to define any codes below "g\l account, resource and item charge".
That's all about it.
Jemmy
I think what you are after is filtering out some data, i.e. when selecting Item, you only want to print sales invoice lines where the type = item, but not show any lines for type=g/l Account, etc?
In that case:
On the trigger "Sales Invoice Line" - OnPreDataItem(), add the following line of code....
"Sales Invoice Line".setrange(type,InputType);
Cheers,
Gus
still problems
Sales Invoice Line - OnPreDataItem()
"Sales Invoice Line".SETRANGE(Type,InputType);
end
sales invoice line onAfterGetRecord
IF InputType = "Sales Invoice Line".Type::Item THEN BEGIN
//counter:=COUNT;
TotalCost:="Unit Cost (LCY)" * Quantity;
Profit:="Line Amount" - TotalCost;
IF "Line Amount" <> 0 THEN
Margin:=Profit / "Line Amount" * 100
ELSE Margin :=0 ;
TTotalCost += TotalCost;
TotalSales += "Line Amount";
TotalProfit += Profit;
IF TotalSales <> 0 THEN
TotalMargin:=TotalProfit / TotalSales * 100
ELSE TotalMargin :=0 ;
GTotalCost += TTotalCost;
GTotalSales += TotalSales;
GTotalProfit := GTotalSales - GTotalCost;
IF GTotalSales <> 0 THEN
GTotalMargin:=GTotalProfit/GTotalSales * 100
ELSE
GTotalMargin := 0;
END;
after inserting this
"Sales Invoice Line".SETRANGE(Type,InputType); code in OnPreDataItem it works fine when i filter by a single record example
Field Filter
No. MDS
and choose the option string from the request.
But when i do not filter and choose on of the option string e.g. Item it retrieve record Item and Account G\L
pls help.
thanks
Firstly make sure that your InputType option field has got options same as the Type field in Sales invoice line ( i mean in an order ,G/L Account,Item,Resource,Fixed Asset,Charge (Item))
Secondly, dont filter on Type in the Dataitem. Use only option field ItemType. ( dont use both as well.)
Thirdly,For more clarity can you use
If "Sales Invoice Line".Type::Item = InputType
instead of
If InputType = "Sales Invoice Line".Type::Item
I think th eproblem may be the way you have declared the options of the option field. Please check
I have just stumbled across this thread and am very confused by a comment made in the previous post (by lakshmivalluru)
I would have to say that: If InputType = "Sales Invoice Line".Type::Item
is a lot more logical (therefore clearer) to use than:
If "Sales Invoice Line".Type::Item = InputType
The reason is this: We are interested in the value of InputType so that should be the subject of the expression. By putting the constant first the constant becomes the subject.
Hopefully I have voiced my opinion clearly enough...
Please voice any other opinions...