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)]
display Name journalName(LedgerEntryJournal _this)
{
return LedgerJournalTable::find(_this.JournalNumber).JournalName;
}

[SysClientCacheDataMethodAttribute(true)]
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 reference value from the method to Event handler method:

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

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

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

Data entity methods - Event handler

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:

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;
}
}

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 get ledger dimension values for active account structure in AX 2012 AX7 D365

public static DimensionValue dimensionDisplayValue(LedgerDimensionAccount _ledgerDimension, Name _dimensionName ) { DimensionA...