Sunday, June 20, 2021

Get Display values from Ledger Dimension x++

 class GlobalDisplayFromLedgerDimension

{

    public static str displayValue(RefRecId _LedgerDim,Name _AttribName)

    {

        DimensionAttributeLevelValueAllView dimAttrView;

        DimensionAttribute                  dimAttr;

        

        select DisplayValue from dimAttrView where dimAttrView.ValueCombinationRecId == _LedgerDim

          join dimAttr

            where dimAttr.RecId == dimAttrView.DimensionAttribute

            && dimAttr.Name == _AttribName;

        return dimAttrView.DisplayValue;

    }


}

Get company fiscal year


Ledger::FiscalCalendar()

Friday, June 18, 2021

Difference between Ledger dimension and Financial dimension

 




The Picture above is "Set of ledger" or "Financial dimension"
The Picture below is Ledger Dimension

Object reference not set to an instance of an object D365 F&O

Some of the objects are not compiled and synchronized with DB. we have to build model wise and synchronization and then one full build, it will be resolved.

Some times restart the services and its done

Using SSMS for unit testing

 Search SSMS in start menu

Select SQL Server Management Studio 18

Run it as administrator

Fill in the server name

Click on "Connect"

In the actionpane click on "New Query"

In the availabl databases, select AxDB

No you can write the SQL query for unit testing

EXAMPLE :

select * from BANKACCOUNTTRANS

where BANKACCOUNTTRANS.ACCOUNTID = 'AUB-BHD'

and BANKACCOUNTTRANS.TRANSDATE >= '12/1/2019'

and BANKACCOUNTTRANS.TRANSDATE <= '12/31/2020'


How to restore DB from UAT to Dev D365 FO

Open CMD in administrator mode


Go to :

cd C:\Program Files\Microsoft SQL Server\150\DAC\bin

(i.e sometimes in 130)


Now create a new DB in SSMS (In my case name: AXDBFromUAT)


now run this command 

 SqlPackage.exe /a:import /sf:C:\DBFromUAT\SOLERPUATbackup.bacpac /tsn:localhost /tdn:AXDBFromUAT /p:CommandTimeout=32000

Please Note:

{

    If you are facing below error:

    *** Changes to connection setting default values were incorporated in a recent release.  More information is available at https://aka.ms/dacfx-connection

    *** Error importing database:Could not import package.

    Unable to connect to target server 'localhost'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server.

    A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)

    The certificate chain was issued by an authority that is not trusted.

    *** The settings for connection encryption or server certificate trust may lead to connection failure if the server is not properly configured.


    use below command
    SqlPackage.exe /a:import /sf:C:\DBFromUAT\SOLERPUATbackup.bacpac /tsn:localhost /tdn:AXDBFromUAT /p:CommandTimeout=32000 /ttsc:True

}

(your package is saved in C:\DBFromUAT\SOLERPUATbackup.bacpac)


Now rename the older DB from AXDB to AXDBOld 

and new DB from AXDBFromUAT to AXDB

using the following commands


USE master;  

GO  

ALTER DATABASE AxDBUAT SET SINGLE_USER WITH ROLLBACK IMMEDIATE

GO

ALTER DATABASE AxDBUAT MODIFY NAME = AxDB ;

GO  

ALTER DATABASE AxDB SET MULTI_USER

GO


Link

Renaming issue

{

SELECT * FROM sys.dm_exec_sessions WHERE database_id = DB_ID('AxDB');

then kill that process

}

for process errors during the renaming

run below query


select 

d.name, 

d.dbid, 

spid, 

login_time, 

nt_domain, 

nt_username, 

loginame

from sysprocesses p 

inner join sysdatabases d 

    on p.dbid = d.dbid

where d.name = 'AxDb'

GO


and kill that process 

How to create custom workflow participant assignment provider type in D365 f&O

 Create a class and Write the following code : 


class GITS_DepartmentManagerParticipantProvider implements WorkflowParticipantProvider

{


    public WorkflowParticipantTokenList getParticipantTokens()

    {

        WorkflowParticipantTokenList tokens = WorkflowParticipantTokenList::construct();

        tokens.add('DeptManager','Department Head');

        return tokens;

    }


    public WorkflowUserList resolve(WorkflowContext _context,WorkflowParticipantToken _participantTokenName)

    {

        str             deptName;

        anytype         tempWorker;

        DirPersonUser   personUser;

        HcmWorker       hcmWorker;

        OMOperatingUnit OMOperatingUnit;

        PurchTable      purchTable;

        WorkflowUserList userList = WorkflowUserList::construct();


        if (!_participantTokenName)

        {

            throw Error("@SYS105453");

        }

        

        select WorkerPurchPlacer from PurchTable

            where PurchTable.RecId == _context.parmRecId();


        deptName = HcmWorker::find(purchTable.WorkerPurchPlacer).primaryDepartmentName();

        

        select hcmWorker from OMOperatingUnit

            where OMOperatingUnit.Name == deptName

            &&    OMOperatingUnit.OMOperatingUnitType == OMOperatingUnitType::OMDepartment;

        tempWorker = OMOperatingUnit.hcmWorker;

        

        select User from personUser

            exists join hcmWorker

                where hcmWorker.Person == personUser.PersonParty

                &&    HcmWorker.RecId  == tempWorker;


        userList.add(personUser.User);


        return userList;

    }


    public static GITS_DepartmentManagerParticipantProvider construct()

    {

        return new GITS_DepartmentManagerParticipantProvider();

    }


}





Now create a "Workflow Participant Assignment Providers"

and put the help text and label "Purch Dept manager"

Available for all workflow template : No

Now in the provider class put in the name of the class that you created earlier i.e "GITS_DepartmentManagerParticipantProvider"

Now create a "Workflow type reference" and put in the then name of the workflow type that you want to provide the assignment on.

Moving Deployment package into UAT using LCS

Go to LCS Portal

Sign in with your credentials


Click on the implementation project

Click on the top ham burger icon

A lookup will popup like below, click on Asset library

A new window will open like below

Now go to the Software deployment package in the left panel

Now click on "+" sign

A new form will be opened like below


Fill in the name and description of the package

Click on "Add a file"

Select the "Deployment folder" and select the package that you want to upload "AXDeployment----"

Now click ok

And now click confirm

Now click on Lifecycle Services on the top left to open the Homepage, Now you will see a screen like below


Now click on the Implementation project as shown in the below picture

Now click on "Full details" on the environment(environment here means UAT, Production) you want the package to deploy to

Now you will see a screen like below

Now click on "maintain" in the Action pane and select "Apply updates", as shown in the picture below

Now a new form will open that will show the deployable packages from your asset library

Now select your "deployment package" 

Now click apply

Now click yes

Now you can see "Servicing" and it takes around 1hr - 2hr or more depending on various factors(Package size, environment, Microsoft servers, etc)

Tables and classes used in PO cycle D365 FO

Tables used :

PurchTable and PurchLine : Contains all purchase order headers regardless whether they have been posted or not.

PurchParmTable and PurchParmLine : Contains information regarding posting Purchase headers and Lines. 

VendPackingSlipJour and VendPackingSlipTrans : Contains posted packingslip headers and lines.

VendInvoiceJour and VendInvoiceTrans : Contains all invoiced purchase order headers and Lines.

VendReceiptsJour and VendReceiptsTrans : Contains posted receipt header and lines.

VendPurchOrderJour and VendPurchOrderTrans : Contains Purchase requisition headers and lines.


Classes used :

PurchTableType and PurchTableLine classes will get called while creating the PurchaseOrders.

PurchFormLetter_PurchOrder,

PurchFormLetter_ApproveJournal,

PurchFormLetter_Invoice,

PurchFormLetter_PackingSlip,

PurchFormLetter_ReceiptsList

These Classes are used to post the PurchaseOrder at various status (packing, invoice etc).

Account payable module Functional in Microsoft Dynamics 365

The purchasing process includes the steps below:


REQUEST FOR QUOTATION ME(BHEJEGA)

QUOTE                         AMAZON(BHEJEGA)

PURCHASE ORDER         ME(BHEJEGA)

SALES ORDER                 AMAZON(BHEJEGA)

INVOICE PROPOSAL         AMAZON(BHEJEGA)

INVOICE                 AMAZON(BHEJEGA)


1. Planned order and purchase requisitions (for material requirements)

     Planned orders are generated automatically in operations planning (master planning)

     Purchase requisitions are internal documents, entered manually, by the person who needs the material. Runs through an approval workflow

2. Request for quotation (for detailed information click here)

     Sent to vendors to require information about the prices and delivery dates

3. Purchase order (for detailed information click here)

     Consists of header – line format. If not approved the status is Draft. If approved or if change management is not active (no need for approval) the status is Approved

     Optionally you can post a purchase inquiry to vendors for validation purposes

     Posting a purchase order confirmation means to save it. All PO confirmations are saved with its original info even after the order maybe subject to changes

     The PO status is indicated by order status and document status?

4. Product receipt (for detailed information click here)

     Reduces the open quantity in PO and increases the the physical quantity in inventory

     The order status becomes Received

5. Invoice receipt (for detailed information click here)

     Register the invoice in the pending vendor invoice form which is usually matched with the PO and product receipt, or otherwise manually in invoice journal

     The order status becomes Invoiced

6. Vendor payment (for detailed information click here)

     Record the payment manually or as a result of payment proposal

     Generates an open vendor transaction , waiting for payment




Tables and classes used in SO cycle D365 FO

Tables used :

SalesTable : Contains all SalesOrder headers regardless whether they have been posted or not.

SalesParmTable and SalesParmLine : Contains detailed information regarding posting sales headers and Lines.

CustConfirmJour and CustConfirmTrans : Contains all Sales Confirmation headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.

CustInvoiceJour and CustInvoiceTrans : Contains all sales all Sales Invoice headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.

CustPackingSlipJour and CustPackingSlipTrans : Contains all Sales PackingSlip headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.


Classes used :

SalesTableType and SaleslineType classes will get called while creating the SalesOrders.

SalesFormLetter_Confirm,

SalesFormLetter_Invoice,

SalesFormLetter_PackingSlip,

SalesFormLetter_PickingLlst,

These classes are used to post the sales order at various status (packing, invoice etc).

How to get formRun from formControl

 [FormControlEventHandler(formControlStr(MyForm, MyButton), FormControlEventType::Clicked)]

public static void MyButton_OnClicked(FormControl sender, FormControlEventArgs e)

{

   FormRun formRun = sender.formRun() as FormRun;

   formRun.myMethod();

}

Temporary files path in AX2012

Temporary file path for AX 2012 : 


 C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\XppIL directory


Tables used in PO and SO

Purchase Order classes and Tables:

--------------------------------------

PurchTableType and PurchTableLine classes will get called while creating the PurchaseOrders.

PurchFormLetter_PurchOrder

PurchFormLetter_ApproveJournal

PurchFormLetter_Invoice

PurchFormLetter_PackingSlip

PurchFormLetter_ReceiptsList

classes will be used to post the PurchaseOrder at various document status (packing, invoice etc).

Tables:

PurchTable contains all purchase order headers regardless whether they have been posted or not.

PurchParmTable and PurchParmLine contains detailed information regarding posting Purchase headers and Lines.

VendPackingSlipJour and VendPackingSlipTrans tables contains posted packingslip headers and lines.

VendInvoiceJour and VendInvoiceTrans tables contains all invoiced purchase order headers and Lines.

VendReceiptsJour and VendReceiptsTrans tables contains posted receipt header and lines.

VendPurchOrderJour and VendPurchOrderTrans tables contains Purchase requisition headers and lines.



SalesOrder Classes and Tables:

--------------------------------------

SalesTableType and SaleslineType classes will get called while creating the SalesOrders.

SalesFormLetter_Confirm

SalesFormLetter_Invoice

SalesFormLetter_PackingSlip

SalesFormLetter_PickingLlst

classes will be used to post the sales order at various document status (packing, invoice etc).

Tables:

SalesTable contains all SalesOrder headers regardless whether they have been posted or not.

The SalesParmTable and SalesParmLine contains detailed information regarding posting sales headers and Lines.

CustConfirmJour and CustConfirmTrans tables contains all Sales Confirmation headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.

CustPackingSlipJour and CustPackingSlipTrans tables contains all sales PackingSlip headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.

CustInvoiceJour and CustInvoiceTrans tables contains all sales all Sales Invoice headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.

Thursday, June 17, 2021

Common tables used in D365 FO

CustTrans - The CustTrans table contains posted transaction information for the customer. 

VendTrans - The VendTrans table contains posted transaction information for the vendor. 

CustSettlement – The CustSettlement table contains information relating to the settlement or reverse settlement of two transactions. They are used to link a transaction with the transaction it was settled against. 

VendSettlement – The VendSettlement table contains information relating to the settlement or reverse settlement of two transactions. They are used to link a transaction with the transaction it was settled against.

CustGroup – The CustGroup table contains a list of groups into which customers can be added. Every customer must specify a CustGroup with which it is associated.

VendGroup – The VendGroup table contains definitions of vendor groups.

CustTable – The CustTable table contains the list of customers for accounts receivable and customer relationship management.

VendTable – The VendTable table contains vendors for accounts payable.

SalesTable – The SalesTable table contains all sales order headers,

regardless of whether they have been posted or not.

PurchTable – The PurchTable table contains all purchase order headers, regardless of whether they have been posted or not.

SalesLine – The SalesLine table contains all sales order lines, regardless of whether they have been posted or not.

PurchLine – The PurchLine table contains all purchase order lines, regardless of whether they have been posted or not.

LedgerTable – The LedgerTable contains the definitions of the general ledger accounts, also called the chart of accounts.

LedgerTrans – The LedgerTrans table contains the posted general ledger transactions.

LedgerAccountCategory – The LedgerAccountCategory contains the financial categories that accounts fall into. The categories are assigned to accounts to allow easier grouping of accounts on financial statements.

Dimensions – The Dimensions table contains the dimension values for all of the defined dimensions. This is explained further later on.

LedgerTableInterval – The LedgerTableInterval table contains ranges of accounts associated with a Total ledger account.

LedgerBalancesTrans – The LedgerBalancesTrans table contains the posted ledger amounts per account and date.

LedgerBalancesDimTrans – The LedgerBalancesTrans table contains the posted ledger.

Increase attachments file size limit in Dynamics 365 F&O

Go to :

Organization administration > Document management > Document management parameters



Now set the max size of file to be uploaded in MB




Get display value from Ledger Dimension

 DimensionAttributeLevelValueAllView dimAttrView;

        DimensionAttribute                  dimAttr;


select DisplayValue from dimAttrView where dimAttrView.ValueCombinationRecId ==   _LedgerDimension

              join dimAttr

                  where dimAttr.RecId == dimAttrView.DimensionAttribute

                  && dimAttr.Name == "Department";


        _Department = dimAttrView.DisplayValue;

Wednesday, June 16, 2021

Get Display values from Default Dimension X++

select DisplayValue from defaultDimensionView 

    where defaultDimensionView.DefaultDimension == this.DefaultDimension

       && defaultDimensionView.Name == 'Department'; 

Get main account Id and Name form LedgerDimension

MainAccountId from LedgerDimension

info(strFmt("%1",LedgerDimensionFacade::getMainAccountFromLedgerDimension(LedgerDimension).MainAccountId));



Name of MainAccountId from LedgerDimension

info(strFmt("%1",LedgerDimensionFacade::getMainAccountFromLedgerDimension(LedgerDimension).Name));

Friday, June 11, 2021

Create and export xlsx in D365 FO X++

 using System.IO;

using OfficeOpenXml;

using OfficeOpenXml.Style;

using OfficeOpenXml.Table;

class ExportToExcel

{        

    public static void main(Args _args)

    {

        HcmWotker hcmWorker;

        MemoryStream memoryStream = new MemoryStream();

        using (var package = new ExcelPackage(memoryStream))

        {

            var currentRow = 1;

            Filename fileName = “Test.Xlsx”;

            var worksheets = package.get_Workbook().get_Worksheets();

            var CustTableWorksheet = worksheets.Add(“Export”);

            var cells = CustTableWorksheet.get_Cells();

            OfficeOpenXml.ExcelRange cell = cells.get_Item(currentRow, 1);

            System.String value = “Personnel Number”;

            cell.set_Value(value);

            cell = null;

            value = “Name”;

            cell = cells.get_Item(currentRow, 2);

            cell.set_Value(value);

            while select hcmWorker

            {

                currentRow ++;

                cell = null;

                cell = cells.get_Item(currentRow, 1);

                cell.set_Value(hcmworker.PersonnelNumber);

                cell = null;

                cell = cells.get_Item(currentRow, 2);

                cell.set_Value(hcmworker.Name());

            }

            package.Save();

            file::SendFileToUser(memoryStream, fileName);           

        }

    }

}

Create and export csv in D365 FO X++

CODE :

        System.IO.Stream        stream;

        TextStreamIo            io;

        System.IO.StreamReader  reader;

        XML                     fileContent;


        io = TextStreamIo::constructForWrite();

        io.write(strFmt("Personnel number,Name"));

        HcmWorker HcmWorker;

        HcmWorker = null;

        while select HcmWorker

        {

            io.write(strFmt("%1,%2",HcmWorker.PersonnelNumber,HcmWorker.name()));

        }

        stream = io.getStream();

        stream.Position = 0;

        reader = new System.IO.StreamReader(stream);

        filecontent = reader.ReadToEnd();


        File::SendStringAsFileToUser(fileContent, 'Template.csv');


Get tax in free text invoice through x++ code

Code :- 

TaxAmount           taxAmount;

CustInvoiceTrans    CustInvoiceTrans;


CustInvoiceTrans =  CustInvoiceTrans::findRecId(5637144576);

taxAmount = Tax::calcTaxAmount(CustInvoiceTrans.TaxGroup, CustInvoiceTrans.TaxItemGroup, CustInvoiceTrans.InvoiceDate,CustInvoiceTrans.CurrencyCode, CustInvoiceTrans.LineAmount, TaxModuleType::FreeTxtInvoice);


info(strfmt("Tax is %1", taxAmount));

Friday, June 4, 2021

How to set default model for new Projects in D365 FO

 Go to :

C:\Users\Administrator\Documents\Visual Studio Dynamics 365\


Open file in notepad "DynamicsDevConfig.xml"


In the file find "DefaultModelForNewProjects"



Replace the model name with your desired model name


TaDa!!!


Important configuration file path for Dynamics 365 FO

 Path for dev configuration file

C:\Users\Administrator\Documents\Visual Studio Dynamics 365\DynamicsDevConfig.xml


Path for web.config

C:\AOSService\webroot\web.config


Path for batch.exe.config

C:\AOSService\webroot\bin\Batch.exe.config



Global variable in D365 FO X++

//Set the value

SysGlobalCache globalCache;

globalCache = ClassFactory.globalCache();

globalCache.set(strFmt("%1%2",curUserId(),"AtulYadav"), 0, "VALUETHATYOUWANT");

//Fetch the value

SysGlobalCache globalCache;

globalCache = ClassFactory.globalCache();

info(strFmt("%1",globalCache.get(strFmt("%1%2",curUserId(),"AtulYadav"), 0)));

 



Ciellos D365FFO Dev Tools

If you are too lazy to make find method ,exist method and much more

Go to the Link


This toolset makes X++ development for D365 for Finance and Operations easier. It consists of numerous utilities that help developers to improve development process. First of all, It is useful for web service creation. Utility generates data contract class from JSON. This tool helps developer to create standard X++ methods like find or exist methods for table and parm method for class member variables. Additionally, developer has possibilities to generate labels from code automatically.

Click on download and the file.

A ".vsix" file should be downloaded. Go ahead and install it. 

Tada!!

How to download Microsoft RDLC Report Designer

If you are trying to edit SSRS report and it opens in xml and not in Report designer

Go to this link


PS : The above download link is basically a link for Visual studio Market place where you can find more interesting tools for visual studio

Click on download and the file.

A ".vsix" file should be downloaded. Go ahead and install it. 

Tada!!



Register userid with admin priviliges D365 FO - Admin User Provisioning

 Go to :

C:\AOSService\PackagesLocalDirectory\bin

look for "AdminUserProvisioning"

It should look like below


Run it in administrator mode



It will take about 5 minutes and your email address will be registered as Administrator


Tuesday, June 1, 2021

Parm and construct method in D365 FO

class A

{

    AccountNum vendAccoutNum;


    public AccountNum parmAccountNum(AccountNum _vendAccountNum = vendAccoutNum)

    {

        vendAccoutNum = _vendAccountNum;

        return vendAccoutNum;

    }


    public static A construct()

    {

        return new A();

    }


    public void assignValue()

    {

        vendAccoutNum = 99;

    }


}



//Where we want to call it

A objA;

anytype x;

objA = A::construct();

objA.assignValue();

x = objA.parmAccountNum();

info(strfmt("%1",x));

//output will be "99"