Wednesday 19 December 2018

D365FO - The generated nested class could not be parsed for the entity ""

Customized entity are not sync with Staging table. 
Include the staging table to the project. 
Build and synchronize the database.

Monday 17 December 2018

Read label of Enum's Element

class ReadlElementLabels
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        nteger         i;
        String255       enumName;
        Container       con =  ["AssetTransType","DimensionLedgerAccountType","InventJournalType","InventTransType","LedgerPostingType","LedgerTransType","PurchStatus"];
        int             x = conlen(con);

        while(x!=0)
        {
            enumName = conpeek(con, x);

            DictEnum de = new DictEnum(enumName2Id(enumName));
       
            for (i=0; i < de.values(); i++)
            {
                info(strfmt(enumName + ", " + int2str(de.index2Value(i)) + ", " + de.index2Symbol(i) + ", " + de.index2Name(i)));
            }
            x--;
        }
    }

}

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.