web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

method contains text constant

(0) ShareShare
ReportReport
Posted on by 1,087

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

I have the same question (0)
  • Suggested answer
    Amir Nazim Profile Picture
    5,994 on at

    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

  • vv1984 Profile Picture
    1,087 on at

    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

  • Velislav Marinov Profile Picture
    75 on at

    You can't use double quotes inside strings. You should use single quotes instead.

    For example:

     info(strFmt("%1, '%2'", 1, 2));

  • Suggested answer
    Martin Dráb Profile Picture
    238,609 Most Valuable Professional on at

    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).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans