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”.

D365/AX7:The configuration key on the data entity ‘XXXXX’ is disabled. The tables and fields in the data entity will not be available for use in data management

Issue

The configuration key on the data entity ‘XXXXX’ is disabled. The tables and fields in the data entity will not be available for use in data management.

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”