Showing posts with label D365. Show all posts
Showing posts with label D365. Show all posts

Encryption error occurred with exception or CryptoEncryptionException error in D365 FO - D365 F&O

Hello everyone, 

Today I came across the below error after restoring the data base from a Tier-2 (SIT/UAT/TEST) environment which has integrations enabled (Dual Write, Business Events... etc., etc.,)



Root cause:

There could be many reasons why this issue might have come but in my case this occurred due to the left over records(data looks like API keys, Dual Write configuration details, Azure key vault related data) caused the issue.

X++ Code to Create and Release a Product in D365 F&O

Hello everyone,

Today I came across a requirement for Creating and Releasing a Product in D365 FO. Earlier version Ax 2012 has a lot of class's to achieve the requirement but those got deprecated and below is the new way(at least for me) to achieve the requirement.

Args args;
EcoResProductEntity ecoResProductEntity;
EcoResProductEntityToCrossTableDataAdaptor adaptor;
EcoResProduct product;
EcoResProductReleaseSessionManager productReleaseSessionManager;
EcoResReleaseSessionRecId releaseSessionRecId;
NumberSequenceReference numberSequenceReference = EcoResProductParameters::numRefProductNumber();
NumberSequenceTable numberSequenceTable = numberSequenceReference.numberSequenceTable();
NumberSeq numberSeq = NumberSeq::newGetNumFromId(numberSequenceTable.RecId);
CompanyInfo companyInfo = CompanyInfo::find();

X++ Code to create, validate & post "Project Journal" ( Fee, Hour, Expense type journals) in D365 FO || Ax2012

Hello everyone,

Today i would like to post a code snippet for creating and posting a project journal, by using this we can also Create/post Fee(Revenue), Hour, Expense type journals as well.

static void ProjJournalCreateAndPost(Args _args)
{
       // Variable declaration
        ProjJournalTable            jourTable;  
        ProjJournalTrans            jourTrans;  
        ProjJournalTableData    jourTableData;
        ProjJournalTransData    jourTransData;
        ProjJournalStatic            jourStatic;
        ProjJournalCheckPost    jourPost;
 

X++ Code to Create Zip Files in D365 - D365 F&O

Hello Everyone,

Today we will be looking at, how to create a Zip file by using X++ code, while exporting data from the system. Let us see how the code is build.

using System.IO.Compression;

public void createZipFile(Map _cStoreErrorData)
{
    MapEnumerator mapEnumerator = _cStoreErrorData.getEnumerator();
       
        if (_cStoreErrorData.elements() > 0)
        {
            using(System.IO.MemoryStream zipStream  = new System.IO.MemoryStream())
            {
                using(System.IO.Compression.ZipArchive archive  = new System.IO.Compression.ZipArchive(zipStream, System.IO.Compression.ZipArchiveMode::Create, true))

X++ Code To Use Existing NumberSeq While importing Data via OData Services - D365 F&O

Hello Everyone,

Today we will be looking at using the existing number sequence while importing a record using Odata and to have the record imported with automatic number sequence on any field. We need to overwrite the initValue method of DataEntity. Let us see how is the code is build.

public void initValue()

{
    if  (!this.skipNumberSequenceCheck())
    {
        NumberSeqRecordFieldHandler::enableNumberSequenceControlForField(this,
                                                                         fieldNum(

X++ Code to Post Sales Order Invoice line by line - D365 F&O || AX 2012

Hello Everyone,

Today we will be looking at how to invoice a Sales order line by line. We usually use "SalesFormLetter" class and "run" method to post and SO which will post the entire SO and all the lines in it. Recently I have come across a new requirement while posting an SO i.e.., to post the SO invoice line by line. So lets see how the code is build.


Public static void salesOrderInvoiceByLine(SalesLine    _salesline)
{
        salesFormLetter         salesFormLetter;
        salesFormletterParmData salesFormLetterParmData;
        salesParmUpdate         salesParmUpdate;
        salesParmTable          salesParmTable;
        salesParmLine           salesParmLine;
        salesTable              salesTable;
      
        ttsbegin;
        salesTable  = salesTable::find(_salesline.SalesId);
        salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Invoice, VersioningUpdateType::Initial);

        salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
        salesFormLetterParmData.createData(false);
        salesParmUpdate = salesFormLetterParmData.parmParmUpdate();

        salesParmTable.clear();
        salesParmTable.TransDate                = _salesline.ReceiptDateRequested;
        salesParmTable.Ordering                 = DocumentStatus::Invoice;
        salesParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
        salesParmTable.salesId                  = salesTable.salesId;

X++ Code to get Address Lookup Based On Purpose D365 FO || Ax2012

Hello everyone, 

In our day to day life we(Developers) always come across address requirements very frequently, so today's post is related to it.  

Fetching customer/Vendor address based on purpose.

public static void customerInvoiceAddresslookup(FormStringControl   _control,
                                                                                  DirPartyRecId          _party)
{
    query                                    query;
    QueryBuildDataSource        qbds;
    SysTableLookup                   sysTableLookup;
    LogisticsPostalAddress        address = null;
    DirPartyLocation                   partyLocation;
    DirPartyLocationRole            partyLocationRole;
    LogisticsLocationRole           locationRole;

    query   = new Query();
    sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsPostalAddress), _control);

X++ code for getting "BusinessUnit" Address based on "OmOperatingUnitNumber" & "OmOperatingUnitType" in D365 F&O || Ax 2012

Hi everyone, 

The blow code snippet is used to get the Business unit address based on OmOperationUnitNumber and OmOperationUnitType.

static void getBusinessUnitaddress(Args _args)
{
    OMOperatingUnit   operatingUnits;

    select firstOnly * from operatingUnits
        where operatingUnits.OMOperatingUnitNumber  == "047" && // operating unit number
        operatingUnits.OMOperatingUnitType          == OMOperatingUnitType::RetailChannel; // operating type

    info(strFmt("%1",operatingUnits.primaryAddress()));
}

Proud To Be a DAX Developer :-) 

SSRS Tips: X++ code to get Company Logo in D365 F&O || Ax 2012

Hi Everyone, 

There are multiple ways for presenting Company logo in SSRS reports(i.e. RDP reports). Today I would like to share my way of inserting the company logo into  tempTable.

   // Variable declaration
   CompanyInfo        companyInfo = companyInfo::find();