Set boolean to True when a Item Category

Bor1980
Member Posts: 17
Hi all,
In a report I want to print a text if 1 of the articles in the order contains a certain Item Category Code.
Example order with these items:
Item No. Item Category Code
10000 X
10010 Y
10020 Z
If 1 of these items contains the code X, the text must be printed, otherwise not. In this case, the text must be printed.
I had thought to make this work with this code:
Unfortunately this code doesn't work. What am I doing wrong?
In a report I want to print a text if 1 of the articles in the order contains a certain Item Category Code.
Example order with these items:
Item No. Item Category Code
10000 X
10010 Y
10020 Z
If 1 of these items contains the code X, the text must be printed, otherwise not. In this case, the text must be printed.
I had thought to make this work with this code:
IF SalesLine."Item Category Code" = 'X' THEN gPrintTextA := TRUE ELSE gPrintTextA := FALSE;
Unfortunately this code doesn't work. What am I doing wrong?
Dynamics NAV2016
0
Answers
-
Please have a look here: https://docs.microsoft.com/en-us/dynamics-nav/strpos-function--code--text-0
-
Thank you PurpleHaze
My knowledge is not so great that I can translate this to my situation.
By the way, I chose to set the value of a boolean to TRUE and then display the textbox at that value in the report builder because the text is formatted.Dynamics NAV20160 -
It should be:
IF STRPOS(SalesLine."Item Category Code", 'X') <> 0 THEN gPrintTextA := TRUE ELSE gPrintTextA := FALSE;
0 -
Thank you for your answer!
It now looks like this code looks at the first position?
I am looking for a solution when one of the Sales Lines in an order has Item Category Code 'X' then the boolean must be set to TRUE.
Dynamics NAV20160 -
Ah, so Item Category Code is exactly 'X' and not 'abcXqyz'?
Then forget about STRPOS, your code should be fine and the problem is somewhere else.
Just pure guessing: The variable is not really global, or it is not reset every time (if needed), check your DataSet result (with Ctrl + Alt + F1), try to debug it, put some messages to check variable value...
There are multiple ways, or we need to see how the entire solution looks like, those 4 lines is not enough.0 -
I think you may focus on when it would happen from0
-
Item Category must be 'X'
This is the Dataset of the Report:
These are the Global Variables:
I have added the field 'PrintTextA' in the Layout so that I can see if it is set to TRUE.
I've put the code in the 'Configuration - OnAfterGetRecord()'Dynamics NAV20160 -
And the code is looking at SalesLine field "Item Category Code", did you GET or filter the record variable SalesLine correctly? (You are not looking at "Item Category Code" from this record Configuration but from SalesLine)0
-
Yes, sorry for the confusion. The code was intended as an example. The code I use in the Report is
IF "Item Category Code" = 'U-BED1' THEN BEGIN gPrintTextA := TRUE; END ELSE gPrintTextA := FALSE;
Dynamics NAV20160 -
Yeah, I see, all good.
That`s weird, man! I don`t know, debugging didn`t help?0
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