Monday, June 20, 2016

SQL Server Reporting Services

SSRS is the primary reporting platform for Microsoft Dynamics AX. The default, predefined reports that are provided with Microsoft Dynamics AX run on the Reporting Services platform.

 Reporting Services is a server-based reporting platform that includes a complete set of tools to create, manage, and deliver reports, and APIs that enable you to integrate or extend data and report processing in custom applications. Reporting Services tools work within the Microsoft Visual Studio environment and are fully integrated with SQL Server tools and components.

There are two nodes in the AOT or Application Explorer that apply to Reporting Services reports.



  • SSRS Reports contains the report model elements such as a report that is contained in a reporting project.
  • Dynamics AX Model Projects under the Visual Studio Projects node contains the code and other project files for a reporting project.
Developing  a SSRS report using the Report Data Provider.

Friday, May 29, 2015

Global Address Framework [AX 2012]

The global address book (GAB) framework allows information to be shared across companies and entities. Records in the GAB contain fields for postal address, email address, and other similar information. GAB records also contain fields for the associated person or organization, which is called the party. 

Party ---- An entity that assumes a legally binding role when participating in contractual relationships.  A party can be a person or organization and it can be internal or external to an organization. A person or organization that participates in economic activities. A party can be internal or external to an organization.

Location ---- Location to refer to both a physical location (postal address) and electronic address (contact information). Postal address and contact information cannot exist without a location. A geographic point or region, A physical address, An electronic address,functional facility.


  • DirPartyTable Global address book. This will contain entries for all people and organizations  you deal with, including customers, suppliers, employees, etc. This information is maintained across the entire organization. NB the table structure often refers to address book entries as 'parties'. Generally other records (like customer, supplier, etc) will reference a record in this table by a field named Party.
  • LogisticsLocationThis is a single 'location' that can be attached to one or more address book entries. This is similar in principle to the old 'Address' table from Ax2009, that no longer exists - The main difference now being that the location header always points to an address book entry, whereas in 2009 the Address table could point to anything.
  • LogisticsPostalAddress Note that this is not an address - Physical address details are stored in LogisticsPostalAddress.
  • LogisticsElectronicAddress - A postal address, linked to a LogisticsLocation record via field 'LocationElectronic' address details, such as email, phone, web address etc.
  • DirPartyLocation -Each different type of address is represented as a separate record, delineated by 'Type'. This links to the location record
  • LogisticsLocationRole -  This table links entries in the LogisticsLocation table to an address book entry (DirPartyTable). This defines types of roles that an address are classified as, such as "Delivery", "Invoice", etc
  • DirPartyLocationRole Links a location role type (LogisticsLocationRole) and an address book entry (DirPartyTable).
  • DirPartyPostalAddressView (view) - This is a view that collates address book entries with their linked postal addresses
Tables:-

BankAccountTable(Location)--LogisticsLocation(Recid)--LogisticsPostalAddress(Location)
Example forms The following forms have been updated to use single address logic. 
BankAccountTable 
BankGroup 
IntrastatParameters 
CustBankAccounts 
VendBankAccounts 
HcmWorkerBankAccount

Example forms The following forms have been updated to use multiple address logic:
CustTable (Party-based) 
tutorial_Form_GABPrimitive (Party-based) 
HcmApplicantBasket (Party- and non-party based) 
InventLocation (Non-party based) 
VendTable (Party-based) 
HcmWorker (Party-based)

http://axinternals.blogspot.com/2011/09/basic-address-book-structure-in-ax2012.html
How to update Postal Address for a contact person(  https://msdn.microsoft.com/en-us/library/hh608238.aspx)

Tuesday, April 21, 2015

Dimension in Ax 2012

Understanding the dimensions on ledgerJournalTrans

LedgerJournalTrans has 4 dimensions fields: LedgerDimension, DefaultDimension, OffSetLedgerDimension and offSetDefaultDimension.

You can think of LedgerDimension and OffSetLedgerDimension as holding an account and the dimensions for that account, both in one field. Where as the DefaultDimension and the OffSetDefaultDimension only holds the dimension.

The Fields LedgerDimension and OffSetLedgerDimension are shown in the form as “Account” and “Offset account”. The fields DefaultDimension and OffSetDefaultDimension are shown in the form under the button “Financial Dimension/Account” and “Financial Dimension/Offset Account”.



Which of the fields you have to fill out, depends on the fields Accounttype and OffSetAccountType:
AccountType = Ledger  a fill out LedgerDimension with a mainAccount and dimensions
AccountType = not Ledger a fill out ledgerDimentin with an account (ex CustAccount) and fill out DefaultDimension with dimensions.
OffSetAccountType = Ledger a fill out OffSetLedgerDimension with a mainAccount and dimensions
OffSetAccountType = not Ledger a fill out OffSetledgerDimentin with an account (ex CustAccount) and fill out OffSetDefaultDimension with dimensions.

Look at the example below. The Customer DAT-000001 has dimension show in the form “Enter account financial dimension”. DAT-000001 is info stored in the LedgerDimension and the dimensioninformation is stored in the DefaultDimension. The offset ledgeraccount is 1000 and both this information and the dimensions are shown in the “Offset account” field and stored in the OffSetLedgerDimension. OffSetDefaultDimension is blank.


Upgrading the dimensions in LedgerJournalTrans
Then upgrading the code concerning ledgerJournalTrans it is important to remember, that you need to make sure that both the account and the offset account have there dimensionsfields filled out and that the dimensions are the same, as this is how it was in Ax 4.0.

Ex:
Old code
newJournalTrans.Dimension[6]           = TUSParameter::find().FinDep_DimTransactionTypeId;
newJournalTrans.OffsetAccountType =  LedgerJournalACType::Ledger;
newJournalTrans.OffsetAccount         =  tusFinDepEntrySetup.PreliminaryDebtAccount;

New code:
//old code - newJournalTrans.Dimension[6] = TUSParameter::find().FinDep_DimTransactionTypeId;

//newJournalTrans.DefaultDimension   = newJournalTrans.DefaultDimension merged with TUSParameter::find().FinDep_DimTransactionTypeId as the TransactionType attribute

tusTransactionsType=transactionsType::find(TUSParameter::find().FinDep_DimTransactionTypeId);
newJournalTrans.DefaultDimesion= TUSDimensionServices::addOneTusDimToADefaultDimension
(newJournalTrans.DefaultDimension, DimensionAttribute::getDimAttributeTUSTransactionType(), tusTransactionsType.TransactionType, tusTransactionsType.RecId);
newJournalTrans.OffsetAccountType   = LedgerJournalACType::Ledger;

//old code - newJournalTrans.OffsetAccount  = tusFinDepEntrySetup.PreliminaryDebtAccount;

newJournalTrans.OffSetledgerDimension = DimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(
                                               mainAccountRecId,
                                               DimensionHierarchy::getAccountStructure(mainAccountRecId),
                                               newJournalTrans.DefaultDimension);

How to add dimension on forms

Table - we need to create defaultdimension field with Edt as DimensionDefault and create relation with DimensionAttributeValueSet (Recid) to the DefaultDimension field.

Form - we need to add the table to the datasource part. In the Design side we need to create FinancialDimension Tab with Empty Fields.

Code - we need to write the code in following Methods

Class Declaration

public class FormRun extends ObjectRun
{
    DimensionDefaultingController       dimensionDefaultingController;
}
This object does the work in handling the dimensions. And it does it without that much work from our site.
init
public void init()
{
    boolean financialsDimensionsEnabled = true;
    super();
    dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true, financialsDimensionsEnabled, 0, this, tabFinancialDimensions, "@SYS138491");
    dimensionDefaultingController.parmAttributeValueSetDataSource(KbDimensionTab_ds, fieldStr(KbDimensionTab, defaultdimension));
    dimensionDefaultingController.parmValidateBlockedForManualEntry(true);

    tabFinancialDimensions.enabled(financialsDimensionsEnabled);
}
The first line instantiates the object which takes – among others – the formRun and the empty tab page as parameters.
The second line tells the class what data source and which field on the table it should use when handling the financial dimensions.
The third activates the class. If you have the dimensions on a separate tab page on your form you can call the pageActivated method when that tab page is activated to increase performance.
write
public void write()
{
    super();
     dimensionDefaultingController.writing();
}
active
public int active()
{
    int ret;

    ret = super();
    dimensionDefaultingController.activated();

    return ret;
}
delete
public void delete()
{
    super();
    dimensionDefaultingController.deleted();
}
pageactivated
public void pageActivated()
{
    dimensionDefaultingController.pageActivated();

    super();
}

DAVS- it stores recid of dimension
DAVSI - recid of value .
how to add dimensions on tables

1) Create New table and EDT of Dimension Default to your table.
2) Set the relation of DimensionAttributValueSet table (Recid field) to your table of DimensionDefault.



once create the table as shown above. we need to create View for your table
3) Create View for your table named as DimensionAttributeKbDimension
4) Change the Datasource name as BackingEntity
5) drag the Itemname,Tracking no and Recid to the Field and changed name as Name,Value and Key for the 3 fields.


5) Create and run the following  job to clear the dimension cache:
static void clearCache(Args _args)

{
DimensionCache::clearAllScopes();
info("done");
}


6)GL--Setup--FinancialDimension.Click new and select your table name from the use values from field.


7) enter the dimension name for your table.e.g KbDimension
8) click the financial dimension button for your KbDimension.

9) see the financial dimension form for your table.here we can see yourtable data of itemname and trackingno field.

10) Goto GL--Setup---Chart of Accounts--configure account structures.
11) select anyone of structure. i have selected Account structure P&L and click the edit button.
select the ADD Segement.


12) once selected the value and click ADD Segement button. automatically coloumn will added to the form as shown below

13) finally, click the activate button.


https://sumitsaxfactor.wordpress.com/2011/12/16/getting-individual-dimension-combination-valuesdimension-storage-class-ax-2012/








Friday, April 17, 2015

Number Sequence

1) we need to create EDT as string KBNumSeqCustGroupNum.
2) we need to add code for the particular module. so we have to choose which module we are going to add number sequence.in this case ,am going to add in customer module.Class--NumberSeqModuleCustomer--LoadModule Method






3) Go to OA-Common-Number Sequence . Click Generate Button



Click the details button below and set or change the value as you like in the number sequence, highest and lowest and format.


Click finish button


Go to the Custgroup table and added KBNumSeqCustGroupNum edt to the field and set the allow edit as NO. add the KBNumSeqCustGroupNum edt to overviewgroup in the table.



open the custgroup form. add the following codes .

  1. Write the following code on the Class declaration node
     NumberSeqFormHandler numberSeqFormHandler;

  2. Create a new method on the form and write the following code
    NumberSeqFormHandler numberSeqFormHandler(){
    if (!numberSeqFormHandler){
    //create a reference of number sequence form handler class specifying the         EDT, Data source name and the field of the table
    numberSeqFormHandler =NumberSeqFormHandler::newForm(NumberSeqReference::findReference(extendedtypenum(KBNumSeqCustGroupNum)).NumberSequenceId, element,CustGroup_DS,fieldnum(CustGroup,KBNumSeqCustGroupNum));}return numberSeqFormHandler;
    }

  3. Override the close method of the form and write the following code
    public void close()
    {
        if (numberSeqFormHandler)
        {
            numberSeqFormHandler.formMethodClose();
        }
        super();
    }

  4. Override the create method on the CustGroup data source and add the following code
    public void create(boolean _append = false){
    element.numberSeqFormHandler().formMethodDataSourceCreatePre();
    super(_append);
    element.numberSeqFormHandler().formMethodDataSourceCreate(true);}

  5. Override the write method on the CustGroup data source and add the following code
    public void write(){
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();}

  6. Override the validateWrite method on the CustGroup data source and add the following code
    public boolean validateWrite(){
    boolean ret;
    ret = super();
    ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
    return ret;}

  7. Override the delete method on the CustGroup data source and add the following code
    public
    void delete()
    {
    element.numberSeqFormHandler().formMethodDataSourceDelete();
    super();}

  8. Override the linkActive method on the CustGroup data source and add the following code
    public
    void linkActive()
    {
    element.numberSeqFormHandler().formMethodDataSourceLinkActive();
    super();}
  9.  once we complete the above procedure, just open the custGroup form and click new button automatically number sequence field is added as well as number filled.
http://www.dynamics101.com/2014/09/creating-custom-number-sequences-microsoft-dynamics-ax-2012/

Query in X++ code and AOT

  1. There are two ways to create queries:
  2. 1. Create Static Query using a graphical interface.
  3. 2. Dynamic queries by x++ code using System class.


Statics Query


How to add select button on RunBaseBatch Using Static Query on class.using RunBaseQueryDialog to display the select button on form.


 Simple class.

1) HrmAbsenceCreateTables- is a query.
    HRMAbsenceCreateTables - is a class
    HCMWorker,HCMEmployment,DirPerson - tables are used in the query.

2) WorkCalendarDelete,WmsOrderFinish


3) RunbaseBatch Class without Select button
    Class - EventJobDueDate

4) Inheritance Class
    HcmSkillChartDepartment,HcmSkillGapByJobSkill


Example

5) Table - EcoResColor-lookupProductVariantColor

6) SSRS Class - AssetBalancesPeriodDP, BankAccountStatementDp ,SalesOrderEntryStatisticsDP,
SalesOrderEntryStatisticsContract, SalesOrderEntryStatisticsController.
7) Forms - VendSearchCriterion,VendSearchAddCategory.
.

Dynamic Query

  1. construct query by using X++ code.
JmgPayEventsExport(Method :BuildEmployeeQuery) class is the example of query.

InventUpdate class implements Query to wrire Business logic.

https://community.dynamics.com/ax/b/daxmusings/archive/2011/09/27/query-and-new-related-objects-in-ax-2012.aspx

Wednesday, April 15, 2015

Types Of Lookup In Ax 2012

EDT Lookup

First we need to create table
VetSpeciesTable
1) SpeciesID
2) Name
second we need to create primary index for speciesID , so set allow duplicate vale as No
third we need to set Primary index as speciesid

Create EDT for the Species and set the referencetable. for clear idea , i ill show the below screen shot.





once we have complete the procedure, if we use the above edt speciesID to any  table automatically foreignkey relation will create to current table.we ill get lookup of the table.



Create lookup in form without creating a method from table

Standard Example of code

Lookup in queries

\Forms\DirPartyQuickCreateForm\Data Sources\LogisticsPostalAddress\Fields\CountryRegionId\Methods\lookup


Output of the above code

AR-- All Customers-- Create customers


Creating Custom Lookup Dynamically by using Queries


VendTable we ill write one lookup method to display the additional with the existing lookup.

now we are going to write one lookup method and after that we are going to call this method in form.


Code
public void lookupVendorByCurrency(FormControl _formControl, Currencycode _currency)
{
    Query               query;
    QueryBuildDataSource qbds;
    QueryBuildRange      qbr;
    SysTableLookup      sysTableLookup;

    query = new Query();
    sysTableLookup = SysTableLookup::newParameters(tableNum(VendTable), _formControl,true);
    query.addDataSource(tableNum(VendTable));
    qbr = qbds.addRange(fieldNum(VendTable,Currency));
    qbr.value(queryValue(_currency));
    sysTableLookup.addLookupfield(fieldNum(VendTable,AccountNum),true);
    sysTableLookup.addLookupfield(fieldNum(VendTable,Party));
    sysTableLookup.addLookupfield(fieldNum(VendTable,Currency));
 

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

Go to the Cust table form and click datasource custtable and field vendaccount .create lookup method for thgat field

public void lookup(FormControl _formControl, str _filterStr)
{
    VendTable::lookupVendorByCurrency(_formControl,CustTable.Currency);
}



Output

AR-- All customers--edit button-- Miscellaqneous Details group--vendor account filed

Previously it used to disaplay vendaccount and name.. now we added the currency field in the existing lookup.




Lookup by args

Standard Form Name :AssetDepBookLVPTransferProposal(\Forms\AssetDepBookLVPTransferProposal\Designs\DesignList\TransferToAssetId\Methods\lookup)

Table:Assettable(lookupAccountNumLVP Method)

Tuesday, April 14, 2015

Table properties - Support Inheritance,Extends,Abstract

Example

If you want to set the supportinhertiance to the table,
Step 1;
Create table
set the property as yes to SupportInheritance(before create any filed to the table)
Set yes to Abstract
create new filed as InstanceRelationType by the datatype as Int64
set the InstanceRelationType to the property InstanceRelationProperty

EcoResProduct - Base Table
EcoResProductMaster - Child Table
EcoResDistinctProduct -Child table


In the child table we need to set the property Base table  to Extend and set yes to support inheritance.
You cant create the same name of field in the child table which is already exist in the parent table.



http://axdaily.blogspot.com/2011/04/table-inheritance.html