D365/AX7:Ledger/Financial Dimension Lookup In Form (Segmented Control)

Requirement

Ledger/Financial Dimension Lookup In Form (Segmented Control)

Steps

  1. Create 2 fields LedgerDimension (Int64) & AccountType (Enum-LedgerJournalACType) in table.
  2. Create a table relation of field LedgerDimension to DimensionAttributeValueCombination table.

Capture

 

3. Add fields LedgerDimension (Int64) & AccountType (Enum-LedgerJournalACType)             in form.

Capture.JPG

4. Change the properties of segmented control LedgerDimension:

– Auto declaration : Yes
– Account type field : AccountType
– Controller class : DimensionDynamicAccountController
– Filter expression : %1

5.Override the datasource’s field LedgerDimension modified() method

public void modified()
{
super();
SampleTest_LedgerDimension_ds.refresh();
}

6.Override the Form’s segment entry control LedgerDimension lookup() &                               checkUseCustomLookup() methods.

public boolean checkUseCustomLookup(int _accountTypeEnumValue, int _secondaryAccountTypeEnumValue)
{
boolean returnValue;

LedgerJournalACType accountType = any2Enum(_accountTypeEnumValue);
switch (accountType)
{
case LedgerJournalACType::Bank:
case LedgerJournalACType::Cust:
case LedgerJournalACType::FixedAssets:
case LedgerJournalACType::Project:
case LedgerJournalACType::Vend:
returnValue = true;
break;
default:
returnValue = false;
break;
}

return returnValue;
}

public void lookup()
{
switch (SampleTest_LedgerDimension.LedgerJournalACType)
{
case LedgerJournalACType::Bank:
BankAccountTable::lookupBankAccount(this);
break;
case LedgerJournalACType::Cust:
CustTable::lookupCustomer(this);
break;
case LedgerJournalACType::FixedAssets:
AssetTable::lookupAccountNum(this);
break;
case LedgerJournalACType::Vend:
VendTable::lookupVendor(this);
break;
default:
super();
break;
}
}

Capture

Cheers!

D365/AX7:Refresh caller Form DataSource from a class

Requirement

Refresh caller Form DataSource From a class

Sample Code

class AcxInventBarcodeMoveQuantity
{
static void main(Args args)
{
AcxInventBarcodePrinting inventBarcodePrinting;
FormDataSource formDataSource;
ItemId itemId;
;

inventBarcodePrinting = args.record();

if (inventBarcodePrinting.RecId && inventBarcodePrinting.PrintQty)
{
formDataSource = args.record().dataSource();
ttsbegin;
inventBarcodePrinting.selectForUpdate(true);
inventBarcodePrinting.MovedQty += inventBarcodePrinting.PrintQty;
inventBarcodePrinting.BalanceQty -= inventBarcodePrinting.PrintQty;
if (inventBarcodePrinting.BalanceQty == 0)
{
inventBarcodePrinting.BarcodeFilter = AcxBarcodeFilter::Printed;
}
inventBarcodePrinting.PrintQty = 0;
inventBarcodePrinting.doUpdate();
formDataSource.executeQuery();
 formDataSource.refresh();
formDataSource.allowEdit(true);
ttscommit;
info('Quantity Moved.');
}
}

}

D365/AX7:The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: 7Zip failed to extract package Bin (LCS Package Deployment Failed)

Issue

Error coming at the time of LCS Package Deployment.Error code is….

The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: 7Zip failed to extract package Bin

Resolution

  1. Navigate to folder J:\DeployablePackages OR K:\DeployablePackages OR C:\DeployablePackages and right click on the folder “DeployablePackages”.Untick the checkbox “Read-only” and click on “Apply” button.
  2. Navigate to folder J:\AosService\PackagesLocalDirectory\SystemHealth OR K:\AosService\PackagesLocalDirectory\SystemHealth OR C:\AosService\PackagesLocalDirectory\SystemHealth and right click on the folder “SystemHealth”.Untick the checkbox “Read-only” and click on “Apply” button.

 

D365/AX7: Update Custom Fields In CustTrans/VendTrans From LedgerJournalTrans during the posting of journal

Requirement

Need to update/carry/flow Custom Fields In CustTrans/VendTrans From LedgerJournalTrans during the posting of journal.

Sample Code

[ExtensionOf(classStr(CustVendVoucher))]

final class AcxCustVendVoucher_Extension

{

public void post(

LedgerVoucher _ledgerPostingJournal,

CustVendTrans _custVendTrans,

NoYes _approval,

UnknownNoYes _euroTriangulation,

boolean _withHoldTaxType,

boolean _useSubLedger)

{

LedgerJournalTrans  ledgerJournalTransLocal;

VendTrans   vendTransUpdate;

Common  commonLocal = common;




next post(_ledgerPostingJournal, _custVendTrans, _approval, _euroTriangulation, _withHoldTaxType, _useSubLedger);

if (commonLocal.TableId == tableNum(LedgerJournalTrans))

{

ledgerJournalTransLocal = commonLocal;

if (_custVendTrans.tableid == tableNum(vendTrans))

{

ttsbegin;

//*******NOT Recommended*********

//either update in vendTrans or custtrans

select firstonly1 vendTransUpdate

where vendTransUpdate.RecId == _custVendTrans.RecId;

vendTransUpdate.selectForUpdate(true);

vendTransUpdate.DocumentNum = ledgerJournalTransLocal.accountName();

vendTransUpdate.doUpdate();

ttscommit;

//*******Recommended*********

//or insert record with reference of VendTrans.RecId into a seperate table like AcxVendTrans

}

}

}




}


D365/AX7: Update Custom Fields In BankAccountTrans From LedgerJournalTrans

Requirement

Need to update/carry/flow custom fields in BankAccountTrans  from LedgerJournalTrans during the posting of journal

Sample Code

class AcxBankAccountTrans_Events

{

/// <summary>

///

/// </summary>

/// <param name=”args”></param>

[PreHandlerFor(tableStr(BankAccountTrans), tableMethodStr(BankAccountTrans, insert))]

public static void BankAccountTrans_Pre_insert(XppPrePostArgs args)

{

BankAccountTrans    bankAccountTrans = Args.getThis();

LedgerJournalTrans  ledgerJournalTransOriginal;

;

 

if (bankAccountTrans.SourceRecId && bankAccountTrans.SourceTableId && bankAccountTrans.SourceTableId == tableNum(LedgerJournalTrans))

{

select firstonly1 ledgerJournalTransOriginal

where ledgerJournalTransOriginal.RecId == bankAccountTrans.SourceRecId;

bankAccountTrans.AcxPurchId = ledgerJournalTransOriginal.AcxPurchId;

bankAccountTrans.AcxBankChequeNum = ledgerJournalTransOriginal.PaymReference;

}

}

D365/AX7: “Module dependency graph has cycles” Issue and Resolution

Issuerrrr

Error “Module dependency graph has cycles” is occurring at the time of doing any changes or update in existing model or creating a new model or event at the time of running “Build Models”.

Observation

The reason is when one model is dependent on a second model and the second model is dependent on the first model.It means one model contains a reference of second model and second model also contains the reference of first model.

Resolution

1. Go to the AOSService folder located on the main drive.
2. In the AOSService folder open the PackagesLocalDirectory folder.
3. Now in this folder, you’ll find all the models. Locate your model and open the folder.
4. In this folder locate to Descriptor Folder.
5. Copy this file to any location of your choice and open it in any text editor.
6. Remove the tag that contains the model which is not present and is the source of the error.
7. Finally copy this file back to the original location and replace the file in the destination folder.
8. Refresh models in Visual Studio and you’re good to go.

 

D365/AX7: Update Custom Fields In Inter-company Purchase Orders

Requirement

Need to update custom fields in SalesTable during the creation of Inter-company purchase orders.

Steps

  1. Create a extension class of base class -InterCompanySyncPurchTableType.
  2. Add a new ExtensionMethod “setSalesTableData()”.

Sample Code

[ExtensionOf(classStr(InterCompanySyncPurchTableType))]

final class AcxInterCompanySyncPurchTableType_Extension

{

protected void setSalesTableData()

{

SalesTable  salesTable;

PurchTable purchTableTemp = PurchTable;

AxSalesTable    axSalesTableTemp = axSalesTable;

next setSalesTableData();

salesTable = axSalesTable.salesTable();

axSalesTableTemp.salesTable(salesTable);

salesTable.CustomerRef = purchTableTemp.Orderaccount;

axSalesTableTemp.salesTable(salesTable);

axSalesTable = axSalesTableTemp;

}

}


D365/AX7: Writing a file to a remote FTP/FTP Integration

Requirement

The requirement is writing a FTP file from Microsoft Dynamics 365 for Finance and Operations environment to a remote FTP.

Prerequisites

  1. Valid FTP Url
  2. Valid FTP username
  3. Valid FTP password
  4. FTP Url should be accessible from environment.

Sample Code

static void main(Args args)
{
TextStreamIo textStreamIO = TextStreamIo::constructForWrite();
System.Text.Encoding getUTF8;
System.IO.StreamReader streamReader;
System.Byte[] bytes;
System.Object request,response,credential;
System.Net.FtpWebRequest ftpRequest;
System.IO.Stream requestStream;
System.Net.FtpWebResponse ftpResponse;
Str1260 ftpFileName = "ftp://223.31.75.117" + @"/" + "filename.txt";
System.IO.StreamReader reader;
System.Char[] chars;
container con;
System.IO.Stream stream;
;

textStreamIO.writeExp(['Started']);
textStreamIO.writeExp(['This Is Test', ' For Barcode']);
textStreamIO.writeExp(['End']);

stream = textStreamIO.getStream();
stream.Position = 0;
reader = new System.IO.StreamReader(stream);
getUTF8 = System.Text.Encoding::get_UTF8();
bytes = getUTF8.GetBytes(reader.ReadToEnd());
request = System.Net.WebRequest::Create(new System.Uri(ftpFileName));
ftpRequest = request;
credential = new System.Net.NetworkCredential("username", "password");
ftpRequest.set_Credentials(credential);
ftpRequest.set_ContentLength(bytes.get_Length());
ftpRequest.set_Method("STOR");
ftpRequest.set_Proxy(null);
requestStream = ftpRequest.GetRequestStream();
requestStream.Write(bytes,0,bytes.get_Length());
requestStream.Close();
response = ftpRequest.GetResponse();
ftpResponse = response;
info('Processed.');
}


D365/AX7:Enable maintenance mode on our Dynamics environment for license configuration

Overview

In Microsoft Dynamics 365 for finance & operations, enabling of maintenance mode allows you to change varieties of  settings like license configuration.By default, maintenance mode is turned off.When maintenance mode is turned off you cannot change or edit license configuration.

You can easily enable maintenance mode in development Or UAT Or testing environment but to turn on maintenance mode in a production environment, you must submit a service request.

Steps To Complete

There are two ways you can enable maintenance mode and edit license configuration :

  1. Execute below SQL query on transaction database of environment.After executing the query, restart the environment.                                                                               update dbo.SQLSYSTEMVARIABLES
    set dbo.SQLSYSTEMVARIABLES.VALUE = 1
    where dbo.SQLSYSTEMVARIABLES.PARM = ‘CONFIGURATIONMODE’
  2. RDP on your environment.Run command prompt as administrator. Execute below command in CMD.

K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe –metadatadir K:\AosService\PackagesLocalDirectory –bindir K:\AosService\PackagesLocalDirectory\Bin –sqlserver . –sqldatabase axdb –sqluser <SQL admin user id> –sqlpwd <SQL users password> –setupmode maintenancemode –isinmaintenancemode true

In my case the AOS service path is in K drive but it could be in J drive also.So ensure the correct path of AOS service directory.Once environment will be restarted, you will be able to edit the license configuration.

D365/AX7:Configuration key not enabled for the entity ‘XXXXX’

Issue

Configuration key not enabled for the entity ‘XXXXX’.

Observation

Data import/export framework requires entity list is up-to-date. Refresh of Entity list is pending.

Resolution

  1. Go to Workspaces.
  2. Select Data Management.
  3. Open “Framework parameters”.
  4. Under “Data import/export framework parameters”, select fast tab “Entity Settings” and click on “Refresh Entity List”.

Microsoft Dynamics AX, Microsoft Dynamics 365 for Finance and Operations, D365 FO, Retail, SQL, Microsoft Power Apps, Microsoft Power BI, Microsoft Azure, Logic Apps, Microsoft Flow, Microsoft power automate, Microsoft Power Platform,.Net, X++, C#, Power BI DAX, Data Warehousing, Microsoft Analysis Services, SQL Server Reporting Services

%d bloggers like this: