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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Create class header through code in ax 2012

(0) ShareShare
ReportReport
Posted on by

HI All,

Is there a way to create class header in the class declaration of ax 2012, like classes, forms, queries have class declaration, can we create a header at the top of this class declaration? I want the following header for the class declarations if they don't have this header. If they already have this header in the class declaration then remove that old header add new header, for the new header date always changes(second line of the header).

///<csGetVersion>

///2/2/2015

///</csGetVersion>

Is it possible? If yes please share your thoughts. Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    syed baber Profile Picture
    11,633 on at

    Hi Naga,

    You cannot use two class declarations in one classDeclaration method. The name of the class have to be unique. Can you please elaborate why you want to do this and what is the requirement?

    Thanks,

    Baber.

  • Community Member Profile Picture
    on at

    HI Baber,

    I think i was not clear i just want to add class header like following for class declaration.

    ///<csGetVersion>

    ///2/2/2015

    ///</csGetVersion>

    First i need to check if class declaration has this header or not, if not present add the header for that class declaration.

  • Verified answer
    syed baber Profile Picture
    11,633 on at

    Hi Naga,

    You can add the header by right clicking inside classDeclaration method, select Scripts -> documentation -> Header Template. This will add the following template above class declaration:

    /// <summary>

    ///

    /// </summary>

    /// <remarks>

    ///

    /// </remarks>

    If you want to modify this header according to your own format, you need to add code in the following method:

    \Classes\EditorScripts\documentation_HeaderTemplate

    If you really want to do this, take the contents of this method and create a new method, so that new menu option will appear when you right click.

    Please let me know if you have further queries.

    Thanks,

    Baber.

  • Suggested answer
    Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at

    HeaderTemplate is for XML documentation; that's something else than your pseudo-VCS. You would get errors because your XML schema wouldn't match the expect schema of XML documentation. You can create your own script in EditorScripts class to create your header, but I advise against using documentation comments (///). Use normal comments (//) for comments that don't belong to XML documentation.

    Also note that information about version belongs to version control, not to code. The risk is that you'll create update conflict without any reason.

  • Community Member Profile Picture
    on at

    HI Baber,

    Can i  make a method which will automatically make the header if it is not present in the class declaration i.e without manually going to the editor and right clicking for the header.

    I want a method which can create the header automatically with the following text

    ///<csGetVersion>

    ///2/2/2015

    ///</csGetVersion>

    Thanks in advance.

  • Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at

    You can't change the way how AX kernel create classes; you would have to use your own mechanism, possibly with the class builder.

    Nevertheless unless you give us a good reason, I believe that the requirement itself is wrong and you shouldn't even try to implement it. The same information is already in version control - no need to pollute your code with such comments.

    And if you're not using version control, then this is the problem you should address ASAP.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans