Showing posts with label Ax 2012. Show all posts
Showing posts with label Ax 2012. Show all posts

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

SSRS DrillThrough Reports in Ax 2012

Hi Friends, today I would like to share my learning related to SSRS DrillThrough reports, Please follow the below steps to achieve the DrillThrough functionality.

1.  Open the report for which DrillThrough functionality needs to be applied.
2.  Create a new data method as shown below
3. Rename the newly added data method to PurchaseOrder
4. Open the data method PurchaseOrder and we will find the newly added Business logic project added to the same solution as show below.
Method Content:












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 :-) 

X++ code to get the Mandatory Fields in table in Ax 2012

Hi Friends, To day i would like to post a small job/Snippet which will be helpful in our day to day development to get the list of mandatory fields from a specified table.

Let me put it this way, some times we have to duplicate/Mimic a standard functionality without disturbing the standard flow/objects etc.etc..  in such cases this will be very helpful for us to get the list of mandatory fields from each table, instead of going to the each table and find out the properties.

Please find the below code snippet 

static void CheckMandatoryFieldsOnTable(Args _args)
{
        DictTable   dictTable;
        DictField    dictField;
        Counter      i;

        TableId       tableId = tablenum(SalesTable);//Table name
     
        dictTable = new DictTable(tableId);
 
        info(strFmt("Total No. of fields in: %1 are: %2\n\n\n",tableId2name(tableId),  dictTable.fieldCnt()));

        info('Mandatory Fields are following');

        for (i=1 ; i<=dictTable.fieldCnt() ; i++)
        {
            dictField = new DictField(tableId, dictTable.fieldCnt2Id(i));
            if (dictField.mandatory())
            {
                info(dictField.name());
            }
        }
}

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();

How to write X++ methods on the list page Form in Dynamics AX 2012

Scenario: I have a menu item that calls some class to execute business logic on the list page Form. List pages do not allow writing of code on the Form, as they used interaction class.

Solution: You can write the code on list page buttons by setting DisplayTarget property to “Client” from auto, as shown in the below Fig:1.0


Fig: 1.0
Note: After this change, you won’t be able to use this button on the EP, so if you are thinking of using the same list page on the EP and planning to use the same button there, then do not do it. However if you are using only the Rich client Form then you are good to do this.

Proud To Be a DAX Developer :-) 

What Is The Difference Between OCC and PCC in Ax 2012

Optimistic Concurrency Control (vs) Pessimistic Concurrency Control

Pessimistic Concurrency Control :
                                                    On updating the data, the record gets locked and no one else can access that record for updating. It becomes a read-only record till the lock is released. Once the lock gets released, the record can be locked again and get updated for a different user.

Optimistic Concurrency Control :
                                                    This allows multiple user to open up the same record for updation . Record gets locked only while updating the record. This is the most preferred way of locking for the web application.

Proud To Be a DAX Developer :-)

Calling Sequence Of Methods In FORM Level in Ax 2012

Hi Every one, today i would like to share my knowledge on Calling Sequence Of Methods in Form Level. Each form has a set of standard methods. You can override these methods to change the behavior of the form, respond to user interface events, and customize the appearance of a form.There are also methods on each form data source and on each form control.
Below scenarios gives the information of  method calls in the form level 
  1. Opening the Form.
  2. Creating/Updating/Deleting the record in the Form.
  3. Closing the Form.

What's The Difference Between Passing By Reference & Passing By Value?

Hi Everyone,
Today i would like share information about the topic "Pass by value & Pass by reference". This is topics is very confusing for the beginners, so i have come up with an simple example(definition) to make you understand. Source

Example Scenario : Let Say I want to share a web page with you.


Passing By Reference :
  • If I tell you the URL, I'm passing by reference. You can use that URL to see the same web page witch I can see. 
  • If that page is changed, we both see the changes. 
  • If you delete the URL, all you're doing is destroying your reference to that page - you're not deleting the actual page itself.
Passing By Value :
  • If I print out the page and give you the printout, I'm passing by value
  • Your page is a disconnected copy of the original. 
  • You won't see any subsequent changes, and any changes that you make (e.g. scribbling on your printout) will not show up on the original page. 
  • If you destroy the printout, you have actually destroyed your copy of the object - but the original web page remains intact
Proud To Be a DAX Developer :-)

What is: the Inventory Status Of The Processes involved in Creating SalesOrder & PurchOrder in Ax 2012

Inventory Status of the SalesOrder:

1. Confirm         ==> OnOrder.

2. Picking List   ==> Reservation.
3. Packing Slip  ==> Deducted.
4. Invoice           ==> Sold.



Inventory Status of the PurchOrder:

1. Confirm / PurchOrder                     ==> OnOrder.
2. ReceiptList                                     ==> Registration.
3. Packing Slip / Product Receipt       ==> Received.
4. Invoice                                           ==> Purchase.

Proud To Be a DAX Developer :-)

What is: The Process For PurchaseOrder Creation, Class's & Table's Involved In the process in Ax 2012

PurchaseOrder Creation Process:

They are 4 Major Process Steps involved in the Creation Of Purchase Order:
1. Confirmation/PurchOrder.
2. Receipt List
3. Product Receipt
4. Invoice.

1. Confirmation Class's & Tables That are related to Confirmation process are following:
               Tables  : VendPurchOrderJour , VendPurchOrderTrans.
               Class's : PurchFormLetter_PurchOrder.

2. ReceiptList  Class's & Tables That are related to ReceiptList process are following:
            Tables  : VendReceiptListJour , VendReceiptListTrans.
            Class's : PurchFormLetter_ReceiptList.

3. PackingSlip Class's & Tables That are related to PackingSlip process are following:
            Tables  : PackingSlipJour , PackingSlipTrans.
            Class's : PurchFormLetter_ProductReceipt.

4. Invoive Class's & Tables That are related to Invoice process are following:
     Tables  : VendInvoiceJour , VendInvoiceTrans.
     Class's : PurchFormLetter_Invoice.

Proud To Be a DAX Developer :-)

What Is: a Journal & an Journal Entries? What is It's Purpose? in Ax 2012

Definition Of a Journal:
  • A journal details all the financial transactions of a business and which accounts these transactions affect.
  • Typically, journal entries are entered in chronological order and debits are entered before credits.

Definition Of a Journal Entries:
  • A journal entry is the record of a financial transaction recorded (entered) in a journal
    Purpose Of Journal Entries :

  • Journal entries provide foundational information for all other financial reports and are used by auditors to analyze how financial transactions impact a business.

  • Journal entries are assigned to specific accounts using a Chart of Accounts, and the journal entry is then recorded in a ledger account.
Proud To Be a DAX Developer :-)

What is: The Process For SalesOrder Creation, Class's & Table's Involved In the process in Ax 2012

SlaesOrder Creation Process:

They are 4 Major Process Steps involved in the Creation Of Sales Order:
1. Confirmation.
2. Picking List
3. Packing Slip
4. Invoice.

1. Confirmation Class's & Tables That are related to Confirmation process are following:
               Tables  : CustConfJour , CustConfTrans.
                Class's : SalesFormLetter_Confirm.

2. PickingList Class's & Tables That are related to PickingList process are following:
           Tables  : WMSPickingRout , WMSOrderTrans.
           Class's : SalesFormLetter_PickingList.

3. PackingSlip Class's & Tables That are related to PackingSlip process are following:
            Tables  : CustPackingSlipJour , CustPackingSlipTrans.
            Class's : SalesFormLetter_PackingSlip.

4. Invoive Class's & Tables That are related to Invoice process are following:
     Tables  : CustInvoiceJour , CustInvoiceTrans.
     Class's : SalesFormLetter_Invoice.

Proud To Be a DAX Developer :-)

How To: Create & Use AOT Maps In Ax2012

  • Maps are also known as Table Maps/AOT MapsTable Map is a element/object the makes possible to link/associate map fields with fields(same type with different names) in different tables.
  • like, I have create a MAP with field (AccountNum) and Same field exist in CustTable and also in VendTable,so I can associate field in CustTable and in VendTable with Maps, so basically  Maps enables to access the fields with different name in different tables.
Procedure For Creating a AOT Map:
  • I created a Map by navigating to AOT>Data Dictionary>Maps and right click and new and gave it name ‘MapTest’.

  • I have created 4 fields under Fields node in Map (Best Practice drag and drop from EDT).

  • Now the next thing I need to do is to associate the fields in map witch i created with the fields in different tables, let say I am taking two tables (CustTable and VendTable).

Notice that above, four fields that I have created in Maps also exist in CustTable as well as VendTable with different names.


  • To associate fields, go to Mapping node, right click it and click New mapping and enter the table that you want to associate in Mapping Table field as following,

What Is: The Difference Between MapIterator and MapEnumerator In Ax 2012

Hi Friends, 
                
To day i would like to share info about MapIteratot and MapEnumerator, 1st thing to know is that in Ax 2012 "MAPS" are of two types,
1. X++ Maps:
                It can be used as a temp data store for the given scope of a process. This takes us less over head, and is much quicker than a TempTable. For Further reading.
2. AOT Maps:
                 A map can unify the access to similar columns and methods that are present in multiple tables. You associate a map field with a field in one or more tables. This enables you to use the same field name to access fields with different names in different tables. Methods on maps enable you to create or modify methods that act on the table fields that the map references

Difference is mentioned below:

MAP-ITERATOR:   The Mapiterator loops through the complete Map.
MAP-Enumerator: Map Enumerator class is like map iterator Class ,But allows the deletion of elements during enumeration where as mapiterator does not.

Proud To Be a DAX Developer :-)

SSRS Tip: Creating Multiple Data Regions In SSRS Reports

Hi Friends,
Today i'll demonstrate how to create multiple data regions/ groups in SSRS reports. A data region in simple definition is a subreport report that shares the parameters and datasets, and is present inside the report design itself. 
  • This and the following procedure will help you understand how multiple data regions can be created in SSRS. The first of the two data regions will display the detailed customer transactions.
Note: 1. 1st we have to create a query using CustTrans and CustTable tables and with following fields as shown below.
           2. We are using "AutoDesign" report while creating reports.  
  • Create a PktCustTransList query, which includes the CustTable and CustTrans tables. Remove the unwanted fields and retain only the fields that are shown in the following screenshot:

  • Open Visual Studio and create a new Report Model Project named PktCustTransReport and create a dataset that refers to the PktCustTransList query.
  • When selecting the fields in the query window, select all the fields and the name data method from CustTable.

How To: Create Related Field Fixed Relation In Ax 2012

Hi Friends,
Creating Relations in Ax 2012 is not that much difficult, today ll see how to do it in "3 Simple and Easy Steps" . Lets Start
Note: An Xpo for this example is provided at the end.


Step 1:




  • Create a BaseEnum  as AccTypeId , with elements as below 
  •             > Customer  - 0
                > Vendor      - 1




    • Create a EDT as AccTypeEDT and in the propertie's you will find a property as EnumType:   Set it to : AccTypeID(Our BaseEnum)



    Let say you have 3 tables as following:
    1. AccTypeTable.
    2. CustomerDetails.
    3. VendorDetails.

    Step 2:
    • Now create  table  AccTypeTable with fields AccountNum(String), AccType(Enum), DepartmentBelongs(String).
    • Note: When Creating AccType Field create a enumType field and in the properties find ExtendedDataType and fill that with our AccTypeEDT witch we created in step 1.