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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

X++ code to add developer comments in AX2012

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

In my earlier post, I provided code to embed user content on headerTemplate comment. In this post, will provide the code to add developer comments whenever a (base)code is modified by any developer.For this, we need to add a new method to class EditorScripts. I created a new method by name Custom_InsertComments with the following code.

public void Custom_InsertComments(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();

    TempStr     tab;
    UserInfo    userInfo;

    #define.Start('Start ->>')
    #define.End('<<-end')
    #define.StartColumn(1)
    #define.EndColumn(2)
    #define.Comment('//')
    #xppTexts
    ;

    select Name from userInfo
         where userInfo.Id == curUserId();

    tab = _editor.selectionStartCol() == #StartColumn ? '' : #tab;

    _editor.gotoCol(#StartColumn);
    _editor.unmark();
    _editor.gotoLine(startline);

    _editor.insertLines(strFmt('%1%2 Developed by %3 %4 - Project:%5 %6 %7', tab, #Comment, UserInfo.name, DateTimeUtil::utcNow(), userInfo.StartupProject, #Start, #newline));
    _editor.gotoLine(endline + #EndColumn);
    _editor.insertLines(strFmt('%1%2 Developed by %3 %4 - Project:%5 %6 %7', tab, #Comment, UserInfo.name, DateTimeUtil::utcNow(), userInfo.StartupProject, #End, #newline));
}

Comment:

CodeTagging1.png

Output would be like:

CodeTagging2.png

Comments

*This post is locked for comments