Tuesday 9 August 2016

Basic information in Ax7

Source code:

The model store is represented as a set of folders and XML artifacts
Model elements represented by XMl file containing metadata and source code
X++ code uses temporary XPP file for editing and debugging, but stored in model element's XMl file

Visual studio replaces Morphx as a development environment
Ax7 is integrated with VS and cannot be install separately. It provides with ax7 development box

Not Support:

EP elements:
  Web
  Data sets
  Visual studio projects
Parts
  Form parts
  Info parts
  Part cue
  Part cue group
projects\private (Shared)
Report Libraries and report
Perspectives
Security process cycle
Jobs
























Data Entity:


































































































Monday 13 June 2016

How to fetch the row count for all tables in a SQL SERVER database

USE  [enter your db name here]
GO
SELECT      SCHEMA_NAME(A.schema_id) + '.' +  A.Name, SUM(B.rows) AS 'RowCount'
FROM        sys.objects A
INNER JOIN sys.partitions B ON A.object_id = B.object_id
WHERE       A.type = 'U'
GROUP BY    A.schema_id, A.Name

GO
----------------------------

SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%MainAssetId%'
ORDER BY schema_name, table_name;


https://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/

Enabling Remote Errors in SSRS In Ax 2012

By default the remote errors property in SQL Server Reporting Services is set to false, which means error messages in a multi-server environment aren't very detailed.  By enabling remote errors, you will get additional error information returned which is more useful than this:
For more information about this error, navigate to the report server on the local server machine, or enable remote errors.

Option 1 to Enable Remote Errors - DB Engine
1.  Connect to the database engine in SSMS and navigate to the ReportServer database.
2.  Query the ConfigurationInfo table to get familiar with it.  Issue the following query:

USE ReportServer
GO

UPDATE ConfigurationInfo
SET Value = 'True'
WHERE Name = 'EnableRemoteErrors'

Option 2 to Enable Remote Errors - Report Server
This option applies to SQL Server 2008 and newer.
1.  Connect to Reporting Services in SSMS.
2.  Right-click on the server node and go to Properties.
3.  On the Advanced page, set the EnableRemoteErrors property to True.



Export label file in ax 2012

static void Exportlabelfile(Args _args)
{
    #AOT
    #Properties
    TreeNodeIterator     templateNodes,templateNodes1;
    TreeNode             templateNode,templateNode1;
    name                 name;
    #define.test(@"\Label Files")
    #define.Back(@"\")
    #define.Languages("Languages")
    SysDictWorkflowType template;
    SysLabelFileExportOKN  export=new SysLabelFileExportOKN();
    ;
    templateNodes = TreeNode::findNode(#test).AOTiterator();
    templateNode = templateNodes.next();
   
    while (templateNode)
    {      
        if(templateNode.AOTLayer() == Global::currentAOLayer())       
        {          
           
            name = #test + #back + templatenode.aotname()+ #back +#Languages;
            templatenodes1 = treenode::findnode(name).aotiterator();
            templatenode1  = templatenodes1.next();
            while(templatenode1)
            {
                export.parmtreenode(templatenode1);           
                export.run();
                templatenode1 = templatenodes1.next();
            }
           
        }
        templateNode = templateNodes.next();
    }
}

A user session on the server could not be created. Try to start the client again. If the problem continues, contact the Microsoft Dynamics AX administrator.

The transaction log for database 'DynamicsAx1' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases

Object Server 01: Dialog issued for client-less session 1: [Microsoft][SQL Native Client][SQL Server]The transaction log for database 'DynamicsAx1' is full.
To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in
sys.databases [UPDATE SYSTEMSEQUENCES SET NEXTVAL=?,RECVERSION=? WHERE ((ID=?) AND (TABID=?))]

Dialog issued for client-less session 1: An error occurred while obtaining new RecId value for the table.

The transaction log for database ' ' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases

Resolve

https://bombtrk.wordpress.com/2011/10/27/the-transaction-log-for-database-is-full-to-find-out-why-space-in-the-log-cannot-be-reused-see-the-log_reuse_wait_desc-column-in-sys-databases/

IMP:
Check the log number

How to comment code In Ax 2012 R3

Go to the EditorScripts Class add few of the new methods which can help you to easily comment your code for best practice.

Comment all the code:
Comment all the code with Ctrl+E+C with shortcut (Or) Select your code right click and go to the
Scripts -> comments-> comment -> click on that you will get your code commented with the help of below code add this method in the EditorScripts class after that test it.

Public void comments_comment(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i;
    #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);
        _editor.insertString(#comment);
    }
}

Un-Comment all the code:

UnComment all the code with Ctrl+E+U with shortcut (Or) Select your code right click and go to the
Scripts -> comments-> uncomment -> click on that you will get your code commented with the help of below code add this method in the EditorScripts class after that test it.

public void comments_uncomment(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i, col;
    str line;
    #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);

        line = _editor.currentLine();

        // Skip leading white space
        for (col = 1; col <= strlen(line); col++)
        {
            if (substr(line, col, 1) != ' ')
            {
                if (substr(line, col, strlen(#comment)) == #comment)
                {
                    _editor.gotoCol(col);
                    _editor.deleteChars(strlen(#comment));
                }
                break;
            }
        }
    }
}

 Insert Hader comments:

Add below method on the EditorScripts class: 

public void comments_insertHeader(Editor e)
{
    e.unmark();
    e.gotoLine(1);
    e.gotoCol(1);

    e.insertLines('// Changed on ' + date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll ) + ' at ' + time2str(timenow(), 11) + ' by ' + curuserid()'\n');

}
For Testing Go to the new jobs right click Scripts -> comments-> InsertHeader -> click on that you will get comment on your code header side.

Start comments:

Add below method on this class EditorScripts , and test in the job

public void comments_Started(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i;
   // #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);
        //_editor.insertString(#comment);
        _editor.insertLines('// Changes started on ' + date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll ) + ' at ' + time2str(timenow(), 1, 1) + ' by ' + curuserid() +'\n');
    }
}

End comments:-

Add below method on this class EditorScripts , and test in the job

public void comments_END(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i;
   // #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);
        //_editor.insertString(#comment);
        _editor.insertLines('// Changes End on ' + date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll ) + ' at ' + time2str(timenow(), 11) + ' by ' + curuserid() + '\n');
    }
}


http://stackoverflow.com/questions/27923749/how-to-fix-number-of-blank-rows-in-ssrs

https://sumitsaxfactor.wordpress.com/2012/07/14/create-project-tool-for-developers-ax-2012/