I'm writing an IF / AND Statement using these two fields
recItem."Product Group Code"; (Code)
recItem."Item Category Code"; (Text)
How can i write witghout getting an error?
IF recItem."Item Category Code" = 'S' AND
recItem."Product Group Code" <> 'PCB' THEN BEGIN
END;
*This post is locked for comments
Irrespective of requirements, to get this compiling make sure that the evaluation works OK, meaning that the AND operator gets on left and right side a boolean result. This means the code should be like this:
IF (recItem."Item Category Code" = 'S') AND
(recItem."Product Group Code" <> 'PCB')
THEN BEGIN
END;
By using the brackets (recItem."Item Category Code" = 'S') is evaluated to either TRUE or FALSE. Same applies to (recItem."Product Group Code" <> 'PCB').
If you do not use the bracket the compiler will evaluate first this part:
'S' AND recItem."Product Group Code"
where the logical operator AND expects two values that are Boolean and now gets two string values.
Lewis, NAV will not allow you to use AND between Text and Code.
Instead you can write like this:
IF recItem."Item Category Code" = 'S' then begin
if recItem."Product Group Code" <> 'PCB' THEN BEGIN
//Do your stuff here
END;
END;
-Yogesh Kulkarni
Please verify, if you find answer helpful.
Can you elaborate more on your requirement?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156