15 December 2017

How to get ledger dimension values for active account structure in AX 2012 AX7 D365

public static DimensionValue dimensionDisplayValue(LedgerDimensionAccount _ledgerDimension, Name _dimensionName )
{
DimensionAttributeLevelValueAllView dimAttrView; //View that will display all values for ledger dimensions
DimensionAttribute dimAttr; //Main dimension attribute table


select DisplayValue from dimAttrView
where dimAttrView.ValueCombinationRecId == _ledgerDimension //generalJournalAccountEntry.LedgerDimension
join BackingEntityType from dimAttr
where dimAttr.RecId == dimAttrView.DimensionAttribute
&& dimAttr.Name == _dimensionName; // Dimension field name

return dimAttrView.DisplayValue;
}

11 December 2017

AX 7 Dynamics 365 operations display methods

[ExtensionOf(tableStr(LedgerEntryJournal))] // this refers to table extension
final class TTLLedgerEntryJournal_Extension // class name must post with _Extension
{

[SysClientCacheDataMethodAttribute(true)]
public static display Name journalName(LedgerEntryJournal _this)
{
return LedgerJournalTable::find(_this.JournalNumber).JournalName;
}

[SysClientCacheDataMethodAttribute(true)]
public static display Name journalDescription(LedgerEntryJournal _this)
{
return LedgerJournalTable::find(_this.JournalNumber).Name;
}

}

==========

[ExtensionOf(tableStr(LedgerEntryJournal))] // this refers to table extension
public static class TTLLedgerEntryJournal_Extension // class name must post with _Extension
{

[SysClientCacheDataMethodAttribute(true)]
public static display Name journalName(LedgerEntryJournal _this)
{
LedgerEntryJournal:: // can call the static methods what we defined in the current class/Table
return LedgerJournalTable::find(_this.JournalNumber).JournalName;
}

[SysClientCacheDataMethodAttribute(true)]
public static display Name journalDescription(LedgerEntryJournal _this)
{
return LedgerJournalTable::find(_this.JournalNumber).Name;
}

}

07 December 2017

How To AX7 Dynamics 365 Event handlers and Delegates - How to get the reference parameter value from the method to Event handler method


How to get the control access using event handler in D365 or AX7

CustTable custTable = sender.cursor(); // args.getThis() as CustTable;
FormDataSource custTable_ds = sender.formRun().dataSource("CustTable");
FormRun element = sender.formRun();
FormControl myNewButton = element.design(0).controlName("myControl");
myNewButton.enabled(false);

How to get the reference value from the method to Event handler method: in D365 or AX7

Below example -- _salesLineDataSource refers to the main method variable name to identify.
// Note: IdentifierStr should be the same as the existing method.

salesLineDataSource = args.getArg(identifierStr(_salesLineDataSource));
salesTable = args.getArg(identifierStr(pSalesTable));

===================================

Data entity methods - Event handler in D365 or AX7

DataEntityContextEventArgs contextEventArgs = _eventArgs as DataEntityContextEventArgs;
DataEntityRuntimeContext entityCtx = contextEventArgs.parmEntityContext();
DataEntityDataSourceRuntimeContext dataSourceCtx = contextEventArgs.parmEntityDataSourceContext();

=====================================
How to get the arguments using event handlers in AX7 D365 operation: in D365 or AX7

DataEntityRuntimeContext _entityCtx;
DataEntityDataSourceRuntimeContext _dataSourceCtx;

_entityCtx = args.getArgNum(1);
_dataSourceCtx = args.getArgNum(2);
=====================================

[DataEventHandler(tableStr(HcmAbsenceCodeGroupEntity), DataEventType::MappedEntityToDataSource)]
public static void HcmAbsenceCodeGroupEntity_onMappedEntityToDataSource(Common _sender, DataEventArgs _eventArgs)
{
DataEntityContextEventArgs contextEventArgs = _eventArgs as DataEntityContextEventArgs;
DataEntityRuntimeContext entityCtx = contextEventArgs.parmEntityContext();
DataEntityDataSourceRuntimeContext dataSourceCtx = contextEventArgs.parmEntityDataSourceContext();

if (entityCtx.getDatabaseOperation() == DataEntityDatabaseOperation::Insert
&& dataSourceCtx.name() == dataEntityDataSourceStr(HcmAbsenceCodeGroupEntity, HRMAbsenceCodeGroup))
{
HcmAbsenceCodeGroupEntity hcmAbsenceCodeGroupEntity = _sender as HcmAbsenceCodeGroupEntity;
HRMAbsenceCodeGroup hrmAbsenceCodeGroup = dataSourceCtx.getBuffer();

HcmAbsenceCodeGroupEntityEventHandler::defaultJobIdentificationId(hcmAbsenceCodeGroupEntity);
hrmAbsenceCodeGroup.JmgJobId = hcmAbsenceCodeGroupEntity.JobIdentification;
}
}

=================

DataEventArgs - event for Clicked and retrieve form DS example


FormRun form = sender.formRun();
FormDataSource CustTable_ds = form.dataSource(formDataSourceStr(CustTable,CustTable)) as FormDataSource; //Form

=====================

using post events in AX7 or D365 to get the parameter using args. using query range value Not enum value. Query building and linking table in query.

[PostHandlerFor(classStr(ProjInvoiceChoose), methodStr(ProjInvoiceChoose, addItemTransSaleRange))]
public static void ProjInvoiceChoose_Post_addItemTransSaleRange(XppPrePostArgs args)
{

QueryBuildDataSource itemSaleDataSource;
QueryBuildDataSource inventTableDataSource;
QueryBuildDataSource projItemTransDataSource;
QueryBuildRange itemQueryBuildRange;

itemSaleDataSource = args.getArg(identifierStr(_itemSaleDataSource));

projItemTransDataSource = itemSaleDataSource.addDataSource(tableNum(ProjItemTrans));
projItemTransDataSource.joinMode(false);
projItemTransDataSource.relations(false);
projItemTransDataSource.addLink(fieldNum(ProjItemTrans,ProjTransId),fieldnum(ProjItemTransSale,ProjTransId));

inventTableDataSource = projItemTransDataSource.addDataSource(tableNum(InventTable));
inventTableDataSource.joinMode(JoinMode::InnerJoin);
inventTableDataSource.relations(false);
inventTableDataSource.addLink(fieldNum(ProjItemTrans,ItemId),fieldnum(InventTable,ItemId));
itemQueryBuildRange = inventTableDataSource.addRange(fieldNum(InventTable,HSORentalGrouping));
itemQueryBuildRange.value(SysQuery::valueNot(3));
}
=========================
Report extension MenuItem and Controller. Below is the example for the Customer base data report.

Step1. Duplicate the report and do the required changes.
Step2. Create an extension for the Report output MenuItem and output object to new report what we create in the step1.

Or
If the output menuItem assigned with controller class.

Step1. Duplicate the report and do the required changes.
Step2. Create an EventHandler or COC for the Controller class - getReportName() method.
Step3. In the event handler method, assign the new report to return in this method.

 public static str getReportName(Args _args)
    {
        str reportName;

        if (_args.menuItemName() == menuitemOutputStr(CustBasedata))
        {
            reportName = ssrsReportStr(CustBasedata, Report);
        }
        else if (_args.menuItemName() == menuitemOutputStr(CustListReport))
        {
            reportName = ssrsReportStr(CustListReport, Report);
        }
        else if (_args.menuItemName() == menuitemOutputStr(smmSalesCustItemStatistics))
        {
            reportName = ssrsReportStr(smmSalesCustItemStatistics, Report);
        }

        return reportName;
    }
class smmReportController_EventHandler
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(classStr(smmReportsController), staticMethodStr(smmReportsController, getReportName))]
    public static void smmReportsController_Post_getReportName(XppPrePostArgs args)
    {
        Str reportName;
        smmReportsController  reportsController = args.getThis();
        Args argsLoc = args.getArg(identifierStr(_args));
        //Args argsLoc = args.getArgNum(1);
        if (argsLoc.menuItemName() == menuitemOutputStr(CustBasedata))
        {
            reportName = ssrsReportStr(CustBasedataTRG, Report);
        }     
        args.setReturnValue(reportName);
    }

}

05 December 2017

How to: Disable or Enable an Action Pane Button in D365 - AX7 - Dynamics 365 operations

The below example is for using Event handlers - salesTableInteration is the base class.
class TESTSalesTableInteraction
{
[PostHandlerFor(classStr(SalesTableInteraction), methodStr(SalesTableInteraction, enableHeaderUpdateJournalActions))]
public static void SalesTableInteraction_Post_enableHeaderUpdateJournalActions(XppPrePostArgs args)
{
Page page;
SalesTableInteraction salesTableIntraction = args.getThis() as SalesTableInteraction;
page = salesTableIntraction.page();
page.actionPaneControlEnabled(formControlStr(SalesTable, buttonCreatePurchOrder), true);
}

}

AX7 / D365 Extensions: Extend the validateField Method on a Table

Click here

17 November 2017

Deploy Package in Dynamics 365 Operations manually using AX update installer and runbook

In this blog article, we will see how we can deploy package in Dynamics 365 Operations. This Package can be any latest update, hotfix or deployment package you have created.
Prerequisites:
LCS login
VM Instance
Steps:
1. Download, Extract and Unblock Package
2. Update topology configuration data
3. Generate a runbook from the topology
4. Execute runbook
Download, Extract and Unblock Package
a. Login to LCS and download the Zip file of Deployable Package.
b. After downloading, go to downloaded Zip file properties and select unblock.
c. Extract the Zip file to a non–user folder.
Update topology configuration data
a. Go to extracted folder and open the file “DefaultTopologyData.xml”
b. Populate the file with VM name.
i. Go to This PC -> Properties. Find the name of the machine.
ii. Update the VM name with the machine name in the file.
c. Populate the file with installed components
i. Open a command prompt as an administrator.
ii. Run the command from extracted folder path to see a list of all installed components on the computer.
iii. Update the file with a list of components.

3. Generate a runbook from the topology
a. Run the command to generate a runbook.
AXUpdateInstaller.exe generate -runbookid=[runbookID] -topologyfile=[topologyFile] -servicemodelfile=[serviceModelFile] -runbookfile=[runbookFile]
Example:

b. Runbook will contain instructions in sequential steps to deploy the package.
4. Execute Runbook
a. Import the runbook.
AXUpdateInstaller.exe import -runbookfile=[runbookFile]
Example:

b. Verify the runbook.

c. Execute the runbook.
AXUpdateInstaller.exe execute -runbookid=[runbookID]
Example:

d. Export the runbook.
Export the runbook for future reference, you can use it to refer the steps, time to execute each step and logs for each step.
UpdateInstaller.exe export -runbookid=[runbookID] -runbookfile=[runbookFile]
Example:

how to restore the *.bacpac databse in MS SQL Server - import the bacpak file in MS SQL Server

Import the database

When you import the database, we recommend that you:
•Retain a copy of the existing AxDB database, to allow you to revert to it later if needed.
•Import the new database with a new name, for example AxDB_fromProd.

Copy the *.bacpac file to the local machine from which you will import to ensure the best performance. Open a command prompt as Administrator and run the following commands.

Syntax:
SqlPackage.exe /a:import /sf:D:\Exportedbacpac\my.bacpac /tsn:localhost /tdn: /p:CommandTimeout=1200
Example:
SqlPackage.exe /a:import /sf:J:\Test_DB\Test110617.bacpac /tsn:D365Test /tdn:AxDBTest /p:CommandTimeout=1200

The following list provides an explanation of the parameters:
•tsn (target server name): The name of the SQL Server that you will import to.
•tdn (target database name): The name of the database that you will import to. The database should not already exist.
•sf (source file): The path and file name to import from.


Note

During import, the user name and password are not required because SQL Server will default to Windows authentication for the currently logged on user.

17 October 2017

Dynamics AX 365 Import or install / Export / delete model file / D365 operations

Example for Model import and export in D365 Operations

Import:
c:\AosService\PackagesLocalDirectory\Bin>ModelUtil.exe -import -metadatastorepath=c:\AosService\PackagesLocalDirectory -file="d:\ModelTest.axmodel"

Export:
c:\AosService\PackagesLocalDirectory\Bin>ModelUtil.exe -export -metadatastorepath=c:\AosService\PackagesLocalDirectory -modelname="FleetManagement" -outputpath=c:\Models

Delete model:
c:\AosService\PackagesLocalDirectory\Bin>ModelUtil.exe -delete -metadatastorepath=c:\AosService\PackagesLocalDirectory -modelname="FleetManagement"

Replace:
c:\AosService\PackagesLocalDirectory\Bin>ModelUtil.exe -replace-metadatastorepath=c:\AosService\PackagesLocalDirectory -modelname="FleetManagement" -outputpath=c:\Models

29 September 2017

Dynamics 365 operations default elements / Object XML files storage place


C:\AOSService\PackagesLocalDirectory\ApplicationPlatform\ApplicationPlatform
C:\AOSService\PackagesLocalDirectory\ApplicationFoundation\ApplicationFoundation\

28 September 2017

AX 2012 lookup filter using query

public void lookup()
{
QueryBuildDataSource qbds;
Query query = new Query();
LanguageId language;

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(EcoResProductTranslation), this);
sysTableLookup.addLookupfield(fieldNum(EcoResProductTranslation, Name));
qbds = query.addDataSource(tableNum(EcoResProductTranslation));
language = CompanyInfo::find().LanguageId;
qbds.addRange(fieldNum(EcoResProductTranslation, LanguageId)).value(queryValue(language));
qbds = qbds.addDataSource(tableNum(EcoResProduct));
qbds.joinMode(JoinMode::InnerJoin);
qbds.relations(True);

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

28 August 2017

Dynamics AX caching / Cache lookup in AX 2012

Cache Lookup In AX 2012

Single record caching
Found 
  Found caching will assign for the main table, to find the unique record, like CustTable.
Found and Empty
  Similar to Found, when there is empty record can be cache, will be used for Group Tables like custGroup.
NotInTTS
  Will be used for Transaction tables like CustTrans, because to avoid to cache the NotInTTS records.

Set-based caching
 EntairTable

    This will be used mainly for Parameter table as it contains the single record to cache full table data.

Record Caching
Microsoft Dynamics AX database record caching is a performance-enhancing feature that helps avoid database access when it's not strictly necessary. Retrieving database records from memory instead of the database significantly speeds up data access. Caching can reduce the performance penalty for repetitively accessing the same database records.

Types of Caching

Caching is transparent to the application; however, it's important to know how caching works to optimize its performance in Microsoft Dynamics AX. Following are the types of caching:
Single-record
Set-based
Single-record caching has the following characteristics:
Defined at design time
Moves records to the cache based on the table's CacheLookup property and the type of SELECT statement that is used to retrieve the record
For more information about record caching, see Single-record Caching.
Set-based caching has the following characteristics:
Defined either at design time or in X++ code
Moves sets of records to the cache
Implemented either through the table's CacheLookup property or in code by using the RecordViewCache class

Set-based Caching [AX 2012]

EntireTable Cache
When you set a table's CacheLookup property to EntireTable, all the records in the table are placed in the cache after the first select. This type of caching follows the rules of single record caching. This means that the SELECT statement WHERE clause must include equality tests on all fields of the unique index that is defined in the table's PrimaryIndex property.
The EntireTable cache is located on the server and is shared by all connections to the Application Object Server (AOS). If a select is made on the client tier to a table that is EntireTable cached, it first looks in its own cache and then searches the server-side EntireTable cache. An EntireTable cache is created for each table for a given company. If you have two selects on the same table for different companies the entire table is cached twice.

Single-record Caching [AX 2012]

Record caching is enabled for a table when all the following statements are true:
The CacheLookup property on the table is enabled by setting it to one of the following values:
NotInTTS, Found, FoundAndEmpty.
The record buffer disableCache method has not been called with a parameter of true.
Records are cached for all unique indexes when all the following criteria are met:
The table is cached by having its CacheLookup property set to NotInTTS, Found, or FoundAndEmpty.
The select statement that selects the records uses an equal operator (==) on the caching key. The fields in the where clause of the select statement match the fields in any unique index.



15 August 2017

Event handlers for table methods in Dynamics 365 / AX 7

In the below code, You can see a class which is included with one method for post event handling for ReqPO->ValidateQuantity() method.
According to the D365 concept, have to use the static method for event handler but, in this case, need to return value.
Using the below function we can return value even in a static method.

Below method is to execute after ReqPO->ValidateQuantity() method as a post event method.



Ref: Method for the above event method.




02 August 2017

Customer postal address Primary address X++ code AX 2012 / Logistics postal address city, state and zip code

public LogisticsPostalAddress getPostalAddressByType(DirPartyRecId _party, LogisticsLocationRoleType _type)
{

DirPartyLocation partyLocation;
DirPartyLocationRole partyLocationRole;
LogisticsLocation location;
LogisticsLocationRole locationRole;
LogisticsPostalAddress postalAddress;
LogisticsElectronicAddress electronicAddress;

select firstonly postalAddress
exists join location
where location.RecId == postalAddress.Location
exists join locationRole
where locationRole.Type == _type
exists join partyLocation
where partyLocation.Location == location.RecId &&
partyLocation.Party == _party &&
partyLocation.IsPrimary == NoYes::Yes
exists join partyLocationRole
where partyLocationRole.PartyLocation == partyLocation.RecId &&
partyLocationRole.LocationRole == locationRole.RecId;

return postalAddress;
}

21 June 2017

Event Handlers in Dynamics AX 7 and Dynamics AX 365 - D365

If you want to create a new event handler then have to create a class and define.

Example:
How to get formRun or element in the event handler in D365

 [PostHandlerFor(formStr(AssetTrans), formMethodStr(AssetTrans, init))]
    public static void AssetTrans_Post_init(XppPrePostArgs args)
    {
        FormRun                     formRunElement;
        FormDataSource              formDataSource;
        CustomTableFixedAssetProfileTmp    assetProfileTmp;
        QueryBuildDataSource        dataSource;

        formRunElement = args.getThis();

        if( formRunElement.args().callerName() == formStr(HHD_FixedAssetProfile))
        {           
            assetProfileTmp = formRunElement.args().record();// formRun calles the args which is contains the record of caller form
            formDataSource  = formRunElement.dataSource();
            dataSource      = formDataSource.query().dataSourceTable(tableNum(AssetTrans));
            dataSource.addRange(fieldNum(AssetTrans,BookId)).value(assetProfileTmp.BookId);
            dataSource.addRange(fieldNum(AssetTrans,AssetId)).value(assetProfileTmp.AssetId);
        }
    }

class VendTableHandler
{
[PostHandlerFor(tableStr(VendTable), tableMethodStr(VendTable, insert))] // Post even Handler

public static void VendTable_Post_insert(XppPrePostArgs _args)
{
VendTable vendTable = _args.getThis();

_args.setReturnValue(VendTable::exists(vendTable.AccountNum));
}

}

// For Pre event handler
// [PreHandlerFor(tableStr(VendTable), tableMethodStr(VendTable, insert))]

Note: once you created an event handler for a table method. You can see + symbol for the method left side.

25 May 2017

X++ code to get tax calculation in AX 2012 - Sales tax Line wise to get sales tax.

Tax::calcTaxAmount(salesLine.TaxGroup, salesLine.TaxItemGroup, Systemdateget(), salesLine.CurrencyCode, salesLine.LineAmount, TaxModuleType::Sales);


public TaxAmount taxValue1(SalesLine  _salesLine)
{
    TaxOnItem       TaxOnItem;
    TaxGroupData    TaxGroupData;
    real            TaxAmount;
    TaxValue        TaxValue;
    //SalesLine       SalesLine
    ;

    //select firstOnly from salesLine where salesLine.SalesId == 'YourSalesId';
    if(_salesLine.TaxItemGroup && _salesLine.TaxGroup && _salesLine.LineAmount != 0)
    {
        select TaxOnItem
            where TaxOnItem.TaxItemGroup == _salesLine.TaxItemGroup;      
            if(TaxOnItem)
            {
                select TaxGroupData
                    where TaxGroupData.TaxGroup == _salesLine.TaxGroup
                        && TaxGroupData.TaxCode  == TaxOnItem.TaxCode;
               
                if(TaxGroupData)
                {
                    TaxValue  =  TaxData::find(TaxOnItem.TaxCode, Systemdateget(), 0).TaxValue;
                    TaxAmount = (_salesLine.LineAmount * TaxValue) / 100;
                }
               
            }
       
    }
    return TaxValue;
}

X++ to to get financial dimension value using default dimension in AX 2012

#define.dimProductGroups("ProductGroups")
    #define.dimCostCenters("CostCenters")
    #define.dimDepartments("Departments")


private str getDimensionValue(RecId _dimensionDefault, Str dimName)
{
    DimensionAttributeValueSetStorage   dimStorage;
    Str                                 dimValue;
    Counter                             i;


    // DimensionDefault is a RecId that combines all Dimension Values
    dimStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);

    for (i= 1 ; i<= dimStorage.elements() ; i++)
    {
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == dimName)
        {
            dimValue = dimStorage.getDisplayValueByIndex(i);
        }
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == dimName)
        {
            dimValue = dimStorage.getDisplayValueByIndex(i);
        }
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == dimName)
        {
            dimValue = dimStorage.getDisplayValueByIndex(i);
        }
    }

    return dimValue;
}

Calling:
salesDeliveryLinesTmp.ProductGroup      =   this.getDimensionValue(custPackingSlipTrans.DefaultDimension,#dimProductGroups);
    salesDeliveryLinesTmp.CostCenter        =   this.getDimensionValue(custPackingSlipTrans.DefaultDimension,#dimCostCenters);
    salesDeliveryLinesTmp.Department        =   this.getDimensionValue(custPackingSlipTrans.DefaultDimension,#dimDepartments);

====
Using Dimension name getting default dimension getting dimension value;

private DimensionValue ceDimensionProductGroup(DimensionDefault _dimensionDefault)
{
    DimensionValue                      value;
    DimensionAttributeValueSetStorage   dimStorage;
    int i;

    dimStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);

    for (i=1; i<=dimStorage.elements(); i++)
    {
        if (DimensionAttribute::findByName(CustParameters::find().CeDimensionReportValue3).Name == DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name)
        {
            value = dimStorage.getDisplayValueByIndex(i);
        }
    }

    return value;
}



23 May 2017

SQL server 2012 BackUp database using compression query command


USE [MicrosoftDynamicsAX]
BACKUP DATABASE MicrosoftDynamicsAX
TO DISK = 'D:\Backup\Data\MicrosoftDynamicsAX_BackUp\MicrosoftDynamicsAX.bak'
WITH COPY_ONLY, COMPRESSION
GO


USE [MicrosoftDynamicsAX_model]
BACKUP DATABASE MicrosoftDynamicsAX_model
TO DISK = 'D:\Backup\Data\MicrosoftDynamicsAX_BackUp\MicrosoftDynamicsAX_model.bak'
WITH COPY_ONLY, COMPRESSION
GO

28 April 2017

How to get on hand inventory quantity or Available physical quantity in AX 2012

public InventQty onHandInventory(ItemId itemId, InventSiteId inventSiteId,InventLocationId inventLocation)
{
    InventOnhand    inventOnhand;
    InventDim       _inventDim;
    InventDimParm   inventDimParm;
    InventQty       availQty;
    //inventDim
    _inventDim.InventSiteId = inventSiteId;
    _inventDim.InventLocationId = inventLocation;
    inventDimParm.initFromInventDim(_inventDim);

    inventOnhand = inventOnhand::newParameters(itemId,_inventDim,inventDimParm);

    availQty = inventOnhand.availPhysical();
   // info(strFmt("%1",availQty));
    return availQty;

}

02 March 2017

how to add date range in query value in AX 2012

queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustPackingSlipJour,DeliveryDate));
        queryBuildRange.value(queryRange(fromDate,toDate));
        //queryBuildRange.value(SysQuery::range(fromDate,toDate));

Refreshing SSRS report meta data in Dynamimcs AX 2012 || Refreshing code changes in reports objects in SSRS

When changing parameter or Parameter labels or added new parameter in the Contract class, do the following:
1. In VS, remember to change the prompting string for the parameter.
2. Refresh the Datasets.
3. Build the VS project.
4. Add the Report to the AOT.
5. Delete the Report from the Report Server.
6. Deploy the report in VS.
7. Most importantly, Compile the SSRSReport in the AOT.
8. Go to SSRS report and restore and check the properties: Changed Time is affected or not.
Query changes not affected means:


static void deleteSRSReportQuery(Args _args)
{
SRSReportQuery srsReportQuery;
ttsBegin;
while select forUpdate srsReportQuery
{
srsReportQuery.doDelete();
}
ttsCommit;
}

28 February 2017

how to get different time zones time in AX 2012

static void timeZoneJob(Args _args)
{
    utcDateTime time1,time2;

    time1 = 2017-02-28T11:10:00;

    time2 = dateTimeUtil::applyTimeZoneOffset(time1,TimeZone::GMTPLUS0400YEREVAN); // manul time zone assign
    time2 = dateTimeUtil::applyTimeZoneOffset(time1,DateTimeUtil::getUserPreferredTimeZone()); // user based time zone assign  

    info(strFmt("%1",time2));

// AX 7

// DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone())
}

23 February 2017

How to get sales tax and Purch tax percentage in AX 2012

private TaxValue getTaxPercent(TaxGroup _taxGroup, TaxItemGroup _taxItemGroup)
{
    TaxGroupData    taxGroupData ;
    TaxOnItem       taxOnItem;
    TaxData         taxData;

    select firstonly TaxCode from taxGroupData
        index hint TaxGroupIdx
            where taxGroupData.TaxGroup == _taxGroup
            join taxOnItem
            where taxOnItem.TaxItemGroup == _taxItemGroup &&
                    taxOnItem.TaxCode == taxGroupData.TaxCode;

    select firstonly TaxValue from taxData where taxData.TaxCode == taxGroupData.TaxCode;
    return taxData.TaxValue;

}

17 February 2017

AX 2012 RecordInsertList || how to insert set of records in a single database call in AX 2012

RecordInsertList            insertRecords;
SalesTable                     salesTable;

insertRecords           = new RecordInsertList(tableNum(SalesTradeOverEstTmp)); // Define the Table to insert

while select salesTable
{
salesTradeOverEstTmp.salesId = salesTable.salesId;
salesTradeOverEstTmp.CustAccount salesTable.CustAccount;

insertRecords.add(salesTradeOverEstTmp);
}

insertRecords.insertDatabase();

AX 2012 SSRS DP class debugging code || How to debug an RDP class based SSRS report in AX 2012

static void SRSReportDebuggingJob(Args _args)
{
    CeSalesTradeOverEstTmp  salesTradeOverEstTmp; // temp table
    CeSalesTradeOverEstDP   ceSalesTradeOverEstDP = new CeSalesTradeOverEstDP(); //DP class
    CeSalesTradeOverEstContract ceSalesTradeOverEstContract = new CeSalesTradeOverEstContract();// contract class
   
    ceSalesTradeOverEstDP.parmDataContract(ceSalesTradeOverEstContract);
    ceSalesTradeOverEstDP.processReport();
    salesTradeOverEstTmp = ceSalesTradeOverEstDP.getSalesTradeOverEst();
   
    while select salesTradeOverEstTmp
    {
            info(salesTradeOverEstTmp.SalesId);
    }
   
}

Trial balance export to Azure Blob Storage

The file will be automatically generated from D365 using a batch job. The trial balance file should include all dimensions. (Main-Dept-Cost ...