You are having some X++ code in Dynamics AX 4.0 where the "exists" method of the Label class is called to check if certain Label IDs are present.

But for each constant Label ID you pass to the method "Label::exits" the method is returning "false".

This is because if you do not use the function "literalStr" with the constant Label ID the function "Label.exists" is not receiving the Label ID as string but the resolved Label text instead.

In order to check constant Label IDs with the "Label::exists" method the constant Label ID string has to be passed to the "literalStr" function first before passing it to the "Label::exists" method.

Example:

label.exists("@SYS24359")

Here "exists" is always returning false for the constant string value "@SYS24359" as this Label ID is not "received" by the "label.exists" method.

label.exists(literalStr("@SYS24359"))

By using the "literalStr" function the Label ID will not be resolved to the Label text and "exists" receives a valid Label ID that can be checked for existence.

--author: Alexander Lachner
--editor: Alexander Lachner
--date: 24/04/2009