Wednesday, April 4, 2018

Get next Month in x++

 

How to get next month date in x++

 static void mthName(Args _arg)
{
      Transdate s; ;

      s = nextMth(today());
   print "next month date is " + s;
 
   pause;
} 
 
Happy Daxing! 
 

Monday, April 2, 2018

How to get month Number in x++

How to get month of year in x++

 
static void mthYear(Args _arg)
{
    int s;
    ;
     s = mthOfYr(today());  
    print "Month of year is " + s;
 
    pause;
}

Get month name in X++

How to get name of month in x++

 
static void mthName(Args _arg)
{
    str s;
    ;
 
    s = mthName(8);  
    info(strfmt("Month name is %1" , s));
 
}
 
Happy Daxing! 

Tuesday, June 27, 2017

Run code based on configuration key in dynamics AX 2012

Sometimes you need to run code based on your configuration keys 

Code:


  if  (isConfigurationKeyEnabled (configurationkeynum(keyname)))
   {
                     // Code goes here..
   }
   else
   {
                // do something else
    }



Happing daxing

Facing error while deploying from Visual studio

You get the error when trying to deploy a report either by using VS2013 reporting tool or through AOT


The "GenerateRdlTask" task failed unexpectedly.
System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)

Resolution:
1. Go to Control Panel\System and Security\System
2. Open Advanced system settings and open Environment Variables
3. Create a New Variable
4.Variable name: COMPLUS_LoaderOptimization ; Variable value: 1
5. Click OK
6. Logout from the server and logon again.
7. Open the report using Visual Studio 2013 and deploy the AX report.
8. The report can also be deployed from AOT

Deploy SSRS Report through Power Shell

Here is the command to deploy SSRS Report Through Power Shell

Deploy Single Report

 To deploy a specific report, enter the name of the report. For example, to deploy the CustTransList report, enter  the following command:
Command : Publish-AXReport -ReportName CustTransList

Deploy Multiple Report

To deploy two or more specific reports, enter the names of the reports. For example, to deploy the CustTransList and CustTransOpenPerDate reports, enter the following command:
Command : Publish-AXReport -ReportName CustTransList, CustTransOpenPerDate

Deploy All Report

To deploy all reports, enter the following command:
Command  : Publish-AXReport –ReportName 

Create financial dimension through x++

Here is the code to create/find financial dimension in x++

static RecId findCreateDimension(str _project, str _department)
{
    RecId                               ret;

    DimensionAttributeValueSetStorage   dimStorage;
    DimensionAttributeValue             dimensionAttributeValue;
    DimensionAttribute                  dimensionAttribute;
    ;
    if (_project || _department)
    {
        dimStorage              = new DimensionAttributeValueSetStorage();
        if (_project)
        {
            dimensionAttribute      = AxdDimensionUtil::validateFinancialDimension("project");
            dimensionAttributeValue = AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute, _project);
            dimStorage.addItem(dimensionAttributeValue);
        }
        if (_department)
        {
            dimensionAttribute      = AxdDimensionUtil::validateFinancialDimension("Department");
            dimensionAttributeValue =    AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute,    _department);
            dimStorage.addItem(dimensionAttributeValue);
        }
        ret = dimStorage.save();
    }
    return ret;
}