print a data that is related to the option data type

Leshabela
Member Posts: 35
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;
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
-
hi Leshabela,
It print nothing, did it? :shock:want to run a report, but it should show data from an option data type chosen from request form.
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.
Jemmy0 -
Howzit Leshabela,
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,
Gus0 -
Hi,all!
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
Learning Never End.0 -
Hi,
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 checkLR0 -
Hi,
I have just stumbled across this thread and am very confused by a comment made in the previous post (by lakshmivalluru)Thirdly,For more clarity can you use
If "Sales Invoice Line".Type::Item = InputType
instead of
If InputType = "Sales Invoice Line".Type::Item
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...This isn't a signature, I type this at the bottom of every message0
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
- 320 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