Set boolean to True when a Item Category

Bor1980Bor1980 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:
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

Answers

  • Bor1980Bor1980 Member Posts: 17
    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 NAV2016
  • PurpleHazePurpleHaze Member Posts: 42
    It should be:
    IF STRPOS(SalesLine."Item Category Code", 'X') <> 0 THEN
       gPrintTextA := TRUE
    ELSE
       gPrintTextA := FALSE;
    
  • Bor1980Bor1980 Member Posts: 17
    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 NAV2016
  • PurpleHazePurpleHaze Member Posts: 42
    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.
  • rxqrxqrxq_zydrxqrxqrxq_zyd Member Posts: 19
    I think you may focus on when it would happen from
  • Bor1980Bor1980 Member Posts: 17
    Item Category must be 'X'

    This is the Dataset of the Report:
    d0zce6rxvebw.png

    These are the Global Variables:
    pguuk05cxdbg.png

    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 NAV2016
  • PurpleHazePurpleHaze Member Posts: 42
    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)
  • Bor1980Bor1980 Member Posts: 17
    edited 2021-11-12
    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 NAV2016
  • PurpleHazePurpleHaze Member Posts: 42
    Yeah, I see, all good.
    That`s weird, man! I don`t know, debugging didn`t help?
Sign In or Register to comment.