Wednesday, 5 December 2018

How To: Add deep links\Drill Down\Hyperlink to reports (SSRS)

In the Precision design, field 'Action' property, you can find the expression like:





Syntax will be

=Microsoft.Dynamics.Framework.Reports.BuiltInMethods.GenerateDrillThroughLink(
Parameters!AX_ReportContext.Value,
Parameters!AX_UserContext.Value,
"EcoResProductDetailsExtendedGrid", //Menu ItemName
"Display",
"InventTable", //DataSource i.e. table name on form
"ItemId",
Fields!ItemId.Value)

Thursday, 9 February 2017

Killing AOS in starting\stopping status

Open command prompt in admin mode:-
Type
  1. sc queryex "service name"
e.g. sc queryex AOS60$01
  1. Copy PID
  2. taskkill /f /pid [PID]
e.g. taskkill /f /pid 16452

Wednesday, 8 February 2017

Ax 2012 Sending Email using X++ code Dynamics

static void SendEmail(Args _args)
{
SysEmailParameters parameters = SysEmailParameters::find();
SMTPRelayServerName relayServer;
SMTPPortNumber portNumber;
SMTPUserName userName;
SMTPPassword password;
Str1260 subject,body;
InteropPermission interopPermission;
SysMailer mailer;
System.Exception e;

;
if (parameters.SMTPRelayServerName)
relayServer = parameters.SMTPRelayServerName;
else
relayServer = parameters.SMTPServerIPAddress;
portNumber = parameters.SMTPPortNumber;
userName = parameters.SMTPUserName;
password = SysEmailParameters::password();
subject = "Subject line for the email";
body = "<B>Body of the email</B>";

CodeAccessPermission::revertAssert();

try
{
interopPermission = new InteropPermission(InteropKind::ComInterop);
interopPermission.assert();
mailer = new SysMailer();
mailer.SMTPRelayServer(relayServer,portNumber,userName,password, parameters.NTLM);
//instantiate email
mailer.fromAddress("ax.notification@mycompany.com");

mailer.tos().appendAddress("alirazazaidi@live.com");
mailer.subject(subject);
mailer.htmlBody(body);
mailer.sendMail();
CodeAccessPermission::revertAssert();
info("Email has been send!");
}
catch (Exception::CLRError)

{
e = ClrInterop::getLastException();

while (e)

{
info(e.get_Message());

e = e.get_InnerException();
}
CodeAccessPermission::revertAssert();
//info(e);
info ("Failed to Send Email some Error occure");
}

}

Sunday, 4 September 2016

Use batch processing in AX 2012 using sysframework

1. Create a service operation class ABHISalesTableService having the following class declaration:

class ABHISalesTableService 
{
}

2. Create a new method in the class giving a suitable name like processRecords having the following definition:

[SysEntryPointAttribute(false)]
public void processRecords()
{
    ABHISalesTable   abhiSalesTable;
    int             counter = 0;

    //Determines the runtime
    if (xSession::isCLRSession())
    {
        info('Running in a CLR session.');
    }
    else
    {
        info('Running in an interpreter session.');

        //Determines the tier
        if (isRunningOnServer())
        {
            info('Running on the AOS.');
        }
        else
        {
            info('Running on the Client.');
        }
    }

    //Actual operation performed
    while select forUpdate abhiSalesTable
    {
        ttsBegin;
        abhiSalesTable.Processed = NoYes::Yes;
        abhiSalesTable.update();
        ttsCommit;

        counter++;
    }

    info(strFmt("Successfully processed %1 records.", counter));
}

3. Create an action menu item ABHISalesTableService pointing to SysOperationServiceController.

4. Set the parameters of the action menu item to the service operation just created, ABHISalesTableService .processRecords.

5. Compile the service operation class and generate incremental IL.
6. Click on the action menu item to run the batch job. Check the Batch processing checkbox to run the job in CLR runtime which is the batch server execution environment.
7. Click System administration > Inquiries > Batch jobs to view the status of the job. You may also click on the Log button to view the messages written to infolog during the job execution.

Thursday, 16 June 2016

AX 7 - Element, Model, Projects and Package

There are 4 main components to understand in Visual Studio include Elements, Models, Projects and Packages. To explore more let's have a look at a screenshot of the Application Explorer. Within it, there is an AOT node (Model view)



Elements:-

Elements are AOT objects, for example; Base Enums, Extended Data Types, Tables, Classes, Forms, and Menu items and a lot more.

Model :-
  1. Model is a group of elements that represents the particular solution (Tables, Forms, and Classes e.t.c) 
  2. The definition of the Model is similar to what it was in AX 2012 (AX 2012 Models) 
  3. Model is a design time concept. For example A Fleet Management Model, A Project Account Model
  4. A Model may contains multiple Visual Studio projects. However, a project many only belong to one model
  5. All of the sub-nodes below the AOT node are different models, this is call Model View
Projects:-
  1. Recommended way of development is to create Visual Studio project for all changes and the project always belongs to model, you can think of them is a subset of your model. Why do we have a different concept for model and project? The only reason we have two concepts of a model and a project is, typically AX 7 models are very large and its not a good practice to compile entire model for a simple code change activities during your development.
  2. Project always belongs to a particular model and is basically a subset of elements that belongs a model.
  3. One or more model can constitute a package, typically every package has one model. The reason sometimes we have one or more models in particular package when you customize during overlaying of source code.
Package:-
  1. A Package is a more of a compilation unit and distribution unit to move binaries and any other runtime artefacts that your model need between environments during the development ALM process. For example; moving them from the development box to the Cloud to run.
  2. A Package typically is one or more Packages typically packages into one we called deployment package and this is the unit that you use to move code to Cloud.
  3. A Package is a deployment unit that may contain one ore more models. In addition to elements, it includes more metadata, which is a description data that defines the properties and behaviour of the model.
  4. A Package can be exported into a file which can then be deployed into a staging or production environment.
Keep tuned for more on AX 7.

Monday, 30 May 2016

Add All Objects To TFS


static void versionControl(Args _args)
{
    UtilElements   utilElements;
    TreeNode       treeNode;
 
    //Desired Layer
    UtilEntryLevel utilEntryLevel = UtilEntryLevel::var;
 
    //This container is important, so you don't add a single classMethod to versionControl,
    //If you do that, you are going to have some trouble to check-in them.
    container      conElementType = [UtilElementType::Class,UtilElementType::ConfigurationKey,
                                    UtilElementType::Enum,UtilElementType::ExtendedType,
                                    UtilElementType::Form,UtilElementType::Macro,
                                    UtilElementType::Menu,UtilElementType::Report,
                                    UtilElementType::SecurityKey, UtilElementType::SharedProject,
                                    UtilElementType::Table, UtilElementType::ActionTool,
                                    UtilElementType::DisplayTool, UtilElementType::OutputTool];
 
    //Checking if the recordType is inside the valid container
    boolean isValidForVersionControl(UtilElementType _type)
    {
        return confind(conElementType,_type);
    }
    ;
 
    //If the Version Control is not enable, it does not
    // make sense to add elements to it
    if(SysVersionControlParameters::isVCSEnabled())
    {
        //Iterate over the elements of an specific layer
        while select utilElements
            where utilElements.utilLevel == utilEntryLevel
        {
            //Validate if the UtilElment is to be addded to the versionControl
            //based on the recordType field
            if(isValidForVersionControl(utilElements.recordType))
            {
                //Get the AOT tree node
                treeNode = xUtilElements::getNode(utilElements);
 
                //Used to check if it is already added and other stuff
                if(versionControl.allowCreate(treenode))
                {
                    //Call to the VersionControl Appl class, already instantiated by the client
                    versioncontrol.create(treeNode);
                }
            }
         }
     }
     else warning("Version Control not enabled");
}
 
Comment
 
\Classes\SysTreeNode\canCreate
 
 
/*if (!SysTreeNode::existsInLayer(this.parmTreeNode(), currentLayer))   // check if sub-elements' layer is in layer mask
    {
        error(strFmt("@SYS127511", this.parmTreeNode().treeNodePath(), currentLayer));
        return false;
    }*/
 
 
 

Friday, 27 May 2016

AX SSRS Report times out after 10 minutes (Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

Sometimes when running a report that is going to return a large data set you may get the following error message after 10 minutes:

"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"

Whenever you receive this error the first thing you should look at is your DP class and can performance be improved by rewriting some of your code. If it cant be or this is a default ax report sometimes your only option is to increase the default timeout period.

In order to increase the timeout for an AX SSRS report you need to do the following:

1.) Create a new client config(or copy an existing one.) This is the same config that could be used as your .axc file that is used to access different environments/aos. However this will have larger timeout values in it so only use this on the server mentioned in step 4. You do not need your user's applications config to have these settings.

2.) Update the binding node of "QueryServiceBinding" and change the sendTimeout property from "00:10:00" (10 minutes) to whatever timeout value you like in hh:mm:ss format. You can also update any other timeout setting as well if you like. (Just search for 00:10:00 within the document and replace it with your new time)

3.) Save the new config as  "Microsoft.Dynamics.AX.ReportConfiguration.axc"

4.) Copy the new file Microsoft.Dynamics.AX.ReportConfiguration.axc into the following folder on your sql/ssrs server (inside of the os/windows file system)

C:\Program Files\Microsoft SQL Server\MSRS11.<AOS>\Reporting Services\ReportServer\bin

Note: This is for a sql2012 instance. If you are running a different version of ms sql please refer to the following TechNet article to find the location of your report server bin folder https://technet.microsoft.com/en-us/library/hh389774.aspx if you need help locating it.

5.) Run the report and the report should no longer time out. You do not need to restart the aos, sql or ssrs services in order for the changes to take place once the file is in this folder it should now respect your new timeout settings