Hi,
i'm quite new on AX 2009 and X++ programming.
Just started following Microsoft's official manuals and tutorials.
I've got some doubts about variable declarations in classes.
Say i have to declare a string constant for an info box title, "Text box example".
I declared it in the new() method, but compiler's best practices section says: "method contains text constants".
I've googled it but found little results about. How do you behave in such a scenario?
Thank you in advance
ciao
*This post is locked for comments
It is a best practice to use labels for all texts shown to users. This check is not run for strings in single quotes, so you can use them for some internal, non-GUI values - e.g. COM class names (usually the best approach is to use such strings only in macros, so you have a single point of change).
You can safely deactivate this BP check if you write something what won't be used in production (e.g. prototypes).
You can't use double quotes inside strings. You should use single quotes instead.
For example:
info(strFmt("%1, '%2'", 1, 2));
Got it.
So i basically have to use labels for that?
What's the difference between single quote and double quote text in AX?
Thank you
ciao
it is the best practice error, you better not used the text in double quote, it will give you BP error. if you used like that you cant convert you text to some other language if you need to use your solution in some other language.
better use Label Id or if you need to use the text then use the Macro or single quote text
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,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156