Friday, 18 September 2015

AX 2012 components access and its permissions

Component
Additional permissions that are required to install the component
Databases
  • Membership in the dbcreator server role in Microsoft SQL Server
  • Membership in the securityadmin server role in SQL Server
  • Membership in the db_accessadmin database role in SQL Server for the Microsoft Dynamics AX database
If you install the databases remotely from a computer other than the database server, you must log on to the remote computer by using an account that is an administrator on the SQL Server computer. Setup requires access to SQL Server services.
Application Object Server (AOS)
Membership in the sysadmin role on the instance of SQL Server that you want to connect to
Enterprise Portal for Microsoft Dynamics AX
  • Membership in the System administrator role in Microsoft Dynamics AX
  • Membership in the Administrators group in Windows on the Web server
  • Membership in the Farm Administrators group in Microsoft SharePoint 2010 products
  • Membership in the dbcreator role on the instance of SQL Server that is used for SharePoint 2010 products
  • Membership in the WSS_Content_Application_Pools database role in the SharePoint_Config database
Enterprise Search
  • Membership in the System administrator role in Microsoft Dynamics AX
  • Membership in the Administrator group in Microsoft SharePoint Services
  • Membership in the dbcreator role on the instance of SQL Server that is used for Microsoft SharePoint Services
Help server
Membership in the System administrator role in Microsoft Dynamics AX
Management Reporter (server components)
  • Membership in the sysadmin role on the instance of SQL Server that you want to connect to.
  • To finish the initial configuration of Management Reporter, membership is required in the Administrator role in Management Reporter.
Microsoft SQL Server Reporting Services extensions
Membership in the System administrator role in Microsoft Dynamics AX
Microsoft SQL Server Analysis Services configuration
  • Membership in the System administrator role in Microsoft Dynamics AX
  • Membership in the SQL Server securityadmin server role
  • Membership in the SQL Server db_owner database role for the Microsoft Dynamics AX database
Client
None
Microsoft Office add-ins
None
Remote Desktop Services integration
None
Report Designer for Management Reporter (client component)
None
Debugger
None
Visual Studio Tools
None
Trace Parser
None
Web services on Internet Information Services (IIS)
Membership in the System administrator role in Microsoft Dynamics AX
.NET Business Connector
None
Synchronization proxy
  • Membership in the dbowner database role in the SQL Server database for Microsoft Project Server
  • Membership in the System administrator role in Microsoft Dynamics AX
Synchronization service
Membership in the System administrator role in Microsoft Dynamics AX
Management utilities
None
Retail Headquarters
None
Retail POS
None
Commerce Data Exchange: Synch Service (Retail Store Connect)
To install Synch Service, no additional permissions are required. To configure Synch Service, membership is required in the sysadmin role on the instance of SQL Server that you want to connect to.
Commerce Data Exchange: Real-time Service (Retail Transaction Service)
None
Commerce Data Exchange: Async Server
To install Async Server, no additional permissions are required. To configure Async Server, membership is required in the sysadmin role on the instance of SQL Server that you want to connect to.
Commerce Data Exchange: Async Client
To install Async Client, no additional permissions are required. To configure Async Client, membership is required in the sysadmin role on the instance of SQL Server that you want to connect to.
Retail Channel Configuration Utility (Retail Store Database Utility)
To install the utility, no additional permissions are required. To configure databases, membership is required in the sysadmin role on the instance of SQL Server that you want to connect to.
Retail SDK (Retail POS Plug-ins)
None
Retail Online Channel
None
Retail Server
None
Retail mass deployment toolkit
None
Modern POS
None
Retail channel database
None
Retail hardware station
None
RapidStart Connector
None
Warehouse Mobile Devices Portal
None
Data Import/Export Framework
  • Membership in the dbdatareader and dbdatawriter roles on the instance of SQL Server that you want to connect to
  • Membership in the System administrator role in Microsoft Dynamics AX
VSS writer
Membership in the Administrators group on the computer where Microsoft System Center 2012 Data Protection Manager (DPM) is installed
Connector for Microsoft Dynamics
  • Permission to query for entries in Active Directory
  • Membership in the SQL Server dbcreator server role
  • Membership in the SQL Server securityadmin server role
  • Membership in the sysadmin database role on the SQL Server instance that hosts the Microsoft Dynamics Integration (MSDI) database

Tuesday, 30 June 2015

Copy dimension from one table to another in Ax 2012

Use the below method to copy the dimension from one table another table by passing the default dimension value.

public DimensionDefault copyDimension(
    DimensionDefault _defaultDimension,
    DimensionCopy    _dimensionCopy = DimensionCopy::newFromTable(this, CompanyInfo::findDataArea(this.company()).RecId)
    )
{
    return _dimensionCopy.copy(_defaultDimension);
}


Wednesday, 17 June 2015

Specific dimension display in Ax 2012

private Description DimensionbyDept()
{
    DimensionAttributeValueSetStorage dimStorage;
    Counter i;
    str 20 dim;
    int64 n;

    dimStorage = DimensionAttributeValueSetStorage::find("DefaultDimension");

        for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == 'Department')
        {
            n= dimStorage.getValueByIndex(i);
        }
        dim = DimensionFinancialTag::find(n).Description;

    }
    return dim;

Microsoft Dynamics AX 2012 R3 cumulative update 9

Recently Microsoft released cumulative update 9 for AX 2012 R2 and R3.

Please follow the link to get to know the features comes with latest update pack.

AX 2012 R3 cumulative update 9

Tuesday, 2 June 2015

The call to clear the report server caches failed in AX 2012





You'll be getting the below error when refreshing the Report server caches in
AX 2012 Development ->Tools->Caches-> Refresh report server.








Even if you try to validate the report server configuration too, will end up in error.
Try running Ax 2012 as Run as Administrator and check the same.

Deleting unused Main Account Values in Ax 2012

A financial dimension value is based on the Main Account  record and has been used on a transaction, You cannot delete the Main Account record. 

In order to get rid off un-used dimension values, delete the related records in the following tables
1.DimensionAttributeValueCombination
By default the ledger dimension values are stored in DimensionAttributeValueCombination.
The DimensionAttributeValueCombination table contains information about accounts and various dimensions combinations that are used. Anything that uses dimensions will hold reference to a record on this table. 
2.DimensionAttributeLevelValue
This table contains the usage of  a dimension attribute value in a given dimension hierarchy.
3.DimensionAttributeValueGroup
This table represents a group of values for the specific dimension set.
4.DimensionAttributeValueGroupCombination
It contains the usage of dimension code groups in a  dimension code combination.
It allows a group to be re-used in multiple combination.
5.DimensionAttributeValue
This table contains the values, such as dimension codes, for a specific dimension.

After removing the reference records in the above tables, you can remove main account from its master itself.


Tuesday, 31 March 2015

Mailing PO confirmation report in Ax 2012

PO confirmation report has to be sent mail once gets confirmed.
Default standard Ax will print the report using PurchPurchOrderJournalPrint,
to mail the report, the code has to written in the PurchPurchOrderJournalPrint,doPrint() method
as below
/// <summary>
/// Prints the document.
/// </summary>
protected void doPrint()
{
    this.printConfirmReport();
    this.sendmail(vendPurchOrderJour);

    vendPurchOrderJour.printJournal(this, journalList);
}

private void printConfirmReport()
{
    Args                        parameters = new Args();
    SRSPrintDestinationSettings printSettings;
    SrsReportRunController      controller = new SrsReportRunController();
    PurchPurchaseOrderContract  contract = new PurchPurchaseOrderContract();
    FILENAME                    filename;
    boolean                     newLine;
    Name                        filenamepath;
    ;
    newLine = journalList.first(vendPurchOrderJour);
    parameters.caller(this);
    if (journalList)
    {
        parameters.object(journalList);
    }
    controller.parmReportName(ssrsReportStr(PurchPurchaseOrder, Report));
    contract.parmRecordId(vendPurchOrderJour.RecId);
    contract.parmDocumentTitle("@SYS25545");
    controller.parmReportContract().parmRdpContract(contract);
    controller.parmShowDialog(false);
    printSettings = controller.parmReportContract().parmPrintSettings();
    printSettings.printMediumType(SRSPrintMediumType::File);
    printSettings.fileFormat(SRSReportFileFormat::PDF);
    printSettings.overwriteFile(true); 
    filenamepath = PurchParameters::find().PurchConfirmationFilepath;   
    filename = filenamepath + curext() + '_' +vendPurchOrderJour.PurchOrderDocNum + '.PDF';   
    printSettings.fileName(filename);
    controller.parmArgs(parameters);
    controller.startOperation();
}
private void IMX_sendmail(VendPurchOrderJour _vendPurchOrderJour)
{

SysMailer           mailer = new SysMailer();
SysEmailParameters  parameters = SysEmailParameters::find();
FilePath            filePath;
HcmWorker           hcmWorker;
PurchTable          purchTable;
Name                filename;
;
if (parameters.SMTPRelayServerName)
{
    mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                        parameters.SMTPPortNumber,
                        parameters.SMTPUserName,
                        SysEmailParameters::password(),
                        parameters.NTLM);
}
else
{
    mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                            parameters.SMTPPortNumber,
                            parameters.SMTPUserName,
                            SysEmailParameters::password(),
                            parameters.NTLM);
}
filename = PurchParameters::find().PurchConfirmationFilepath;
purchTable  = PurchTable::find(_vendPurchOrderJour.PurchId);
hcmWorker   = HcmWorker::find(purchTable.Requester);
mailer.subject(_vendPurchOrderJour.PurchId);
mailer.fromAddress(DirPartyTable::findByName(UserInfoHelp::userName(curUserId())).primaryEmail());
mailer.htmlBody('Purchase Order confirmation of ' + _vendPurchOrderJour.PurchId +'.' + 'Please Find the Attachment.');
mailer.tos().appendAddress(hcmWorker.email());
mailer.tos().appendAddress(VendTable::find(purchTable.OrderAccount).email());
filePath = filename + curext() + '_' +vendPurchOrderJour.PurchOrderDocNum + '.PDF';
mailer.attachments().add(filePath);
mailer.sendMail();
CodeAccessPermission::revertAssert();
}

Correct me if am wrong....

Wednesday, 25 March 2015

Copying Document Handling from one document to another document in Ax 2012

How to replicate the same document handling (File,Notes etc) from one document(Sales) to another document (Purchase).
Ex
If we want to show the Sales Document Handling Notes to Purchase Order, when we are creating direct delivery from Sales order to purchase order
then pass the following get the document handling

FromTable = salesTable;
ToTable     = purchTable;
Docu::copy(FromTable,ToTable);

Tuesday, 24 March 2015

Selection Highlighter Extension for Ax 2012

Follow the below link to enhance your Ax client with Editor extension to have the following features in AX client as Visual Studio does.
1.Brace Matching Extension
2.highlight words Extension
3.Outlining Extension
Microsoft Dynamics AX 2012 X++ Editor Extensions 


Friday, 20 March 2015

Job for container looping through Legal entity via X++, AX 2012

static void Containerloop(Args _args)
{
    int i;
    container   allLegalentity;
    str         con;

    allLegalentity = conNull();
    allLegalentity = ['USMF','JPMF','INMF'];

    while (conLen(allLegalentity) > 0)

    {
        i++;
        con = conPeek(allLegalentity,i);

        changeCompany(con)
        {
            // code statement
            info(strFmt("%1)  %2",i,con));

        }

        if (i >= conLen(allLegalentity))
        break;
    }

}

Wednesday, 4 March 2015

Getting exchange rate value in ax 2012

public static CurrencyExchangeRate currencyConversion(CurrencyCode fromCurrencyCode, CurrencyCode toCurrencyCode)
{
    ExchangeRateCurrencyPair exchangeRateCurrencyPair,exchangeRateCurrencyPair2;
    ExchangeRateDisplayFactor exchangeRateDisplayFactor;
    ExchangeRate exchangeRate;
    date validFromDate = dateNull();
    date validToDate = dateMax();


    CurrencyCode _fromCurrencyCode =  fromCurrencyCode;
    CurrencyCode _toCurrencyCode = toCurrencyCode;
    ExchangeRateTypeRecId _exchangeRateType2;
    boolean _getReciprocalIfPrimaryNotFound = true;

    CurrencyExchangeRate exchRateValue;

    _exchangeRateType2 = ExchangeRateType::findByName(Exchange Rate Type).RecId;


    select firstonly ExchangeRateDisplayFactor
        from exchangeRateCurrencyPair
        where exchangeRateCurrencyPair.FromCurrencyCode == _fromCurrencyCode
            && exchangeRateCurrencyPair.ToCurrencyCode == _toCurrencyCode
            && exchangeRateCurrencyPair.ExchangeRateType == _exchangeRateType2;
    if(exchangeRateCurrencyPair.ExchangeRateDisplayFactor)
    {

        select firstonly validtimestate(validFromDate, validToDate) exchangeRate
        where
        exchangeRate.ExchangeRateCurrencyPair == exchangeRateCurrencyPair.RecId;
        exchRateValue = ExchangeRateHelper::displayStoredExchangeRate_Static(
                exchangeRate.ExchangeRate,
                exchangeRateCurrencyPair.ExchangeRateDisplayFactor);
    }
    else
    {
       select firstonly ExchangeRateDisplayFactor
        from exchangeRateCurrencyPair2
        where exchangeRateCurrencyPair2.FromCurrencyCode == _toCurrencyCode
            && exchangeRateCurrencyPair2.ToCurrencyCode == _fromCurrencyCode
            && exchangeRateCurrencyPair2.ExchangeRateType == _exchangeRateType2;

        if(exchangeRateCurrencyPair2.exchangeRateDisplayFactor)
        {
            select firstonly validtimestate(validFromDate, validToDate) exchangeRate
            where exchangeRate.ExchangeRateCurrencyPair == exchangeRateCurrencyPair2.RecId;

            exchRateValue = exchangeRateCurrencyPair2.ExchangeRateDisplayFactor / ExchangeRateHelper::displayStoredExchangeRate_Static(
                exchangeRate.ExchangeRate,
                exchangeRateCurrencyPair2.ExchangeRateDisplayFactor);
        }
    }
    return exchRateValue;
}

Getting Availablephysical for item based on financial Dimension site in Ax 2012

public InventQty getavailablephysicalqty(ItemId _itemId, DimensionDefault _defualtDimension)
{
    InventSum                       inventSum;
    DefaultDimensionView            defaultDimensionView;
    DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;
    DimensionAttributeValueSet      dimensionAttributeValueSet;
    InventSite                      inventSite;
    InventDim                       inventDimtemp,inventDimdummy;

    select firstonly DisplayValue from defaultDimensionView
        where defaultDimensionView.DefaultDimension == _defualtDimension
        && defaultDimensionView.Name == 'CostCenterSYS';

    select DimensionAttributeValueSet from dimensionAttributeValueSetItem
        where dimensionAttributeValueSetItem.DisplayValue == defaultDimensionView.DisplayValue
    join dimensionAttributeValueSet
        where dimensionAttributeValueSet.RecId  == dimensionAttributeValueSetItem.DimensionAttributeValueSet
    join SiteId from inventSite
        where inventSite.DefaultDimension == dimensionAttributeValueSet.RecId;

    inventDimtemp.InventLocationId  = "";
    inventDimtemp.InventColorId     = "";
    inventDimtemp.InventSizeId      = "";
    inventDimtemp.inventBatchId     = "";
    inventDimtemp.InventStyleId     = "";
    inventDimtemp.inventSerialId    = "";
    inventDimtemp.InventSiteId      = inventSite.SiteId;

    inventDimdummy = InventDim::findOrCreate(inventDimtemp);
    inventDimdummy = null;
   
     select PhysicalInvent from inventSum
         exists join inventDimdummy
            where inventSum.ItemId == _itemId
               && inventSum.Closed == NoYes::No     
               && inventSum.InventDimId == inventDimdummy.inventDimId
               && inventDimdummy.InventSiteId == inventSite.SiteId;

    return inventSum.PhysicalInvent;
}

Wednesday, 4 February 2015

Getting Dimension value and description from default dimension in ax 2012

private Description getdimension(DimensionDefault _defualtDimension)
{
    DefaultDimensionView    defaultDimensionView;    
    
    select defaultDimensionView
        where defaultDimensionView.DefaultDimension == _defualtDimension
        && defaultDimensionView.Name == 'CostCenter';    
    
    return defaultDimensionView.dimensionDiscription();   
}

Tuesday, 30 December 2014

Job to get Financial dimension Values in AX 2012

static void FinancialDimension(Args _args)
{
    DimensionAttributeValueSet      dimensionAttributeValueSet;
    DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;
    DimensionAttributeValue         dimensionAttributeValue;
    DimensionFinancialTag           dimensionFinancialTag;
    ProjTable                       projTable;
   
    Select projTable  
       join dimensionAttributeValueSet
           where dimensionAttributeValueSet.RecId == projTable.DefaultDimension
           && projTable.ProjId == "000002"
       join dimensionAttributeValueSetItem
           where dimensionAttributeValueSetItem.DimensionAttributeValueSet == dimensionAttributeValueSet.RecId
       join dimensionAttributeValue
           where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
       join dimensionFinancialTag 
           where dimensionFinancialTag.RecId == dimensionAttributeValue.EntityInstance;
          
       info(strFmt("Description%1", dimensionFinancialTag.Description));
}
  

Friday, 26 December 2014

Creating Customer from AIF c# in AX 2012 R3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.NetworkInformation;
using System.Data;
using System.Data.OleDb;
using CON_ReadCustomer.customer;

namespace CON_ReadCustomer
{
    class Program
    {

        static void Main(string[] args)
        {
            CustomerServiceClient proxy = new CustomerServiceClient();
            proxy.ChannelFactory.Credentials.UserName.UserName = "user@domain";
            proxy.ChannelFactory.Credentials.UserName.Password = "password";

            CallContext context = new CallContext();
            context.Company = "usmf";
            context.LogonAsUser = @"domain\username";
            AxdCustomer customer = new AxdCustomer();

            AxdEntity_CustTable custTable = new AxdEntity_CustTable();
            custTable.AccountNum = "123456";
            custTable.Currency = "USD";
            custTable.CustGroup = "20";
            custTable.OneTimeCustomer = AxdExtType_OneTimeCustomer.Yes;
            custTable.OneTimeCustomerSpecified = true;

            ////Create the party record
            AxdEntity_DirParty_DirPerson party = new AxdEntity_DirParty_DirPerson();
            party.NameAlias = "FirstName";

            ////Set the name fields
            AxdEntity_PersonName personName = new AxdEntity_PersonName();
            personName.FirstName = "FirstName ";
            personName.MiddleName = "MiddleName ";
            //personName.LastName = "LastName ";

            ////Add the names to the party record and set the name sequence
            party.PersonName = new AxdEntity_PersonName[1] { personName };
            party.NameSequence = "FirstLast";

            ////Create a postal address
            AxdEntity_DirPartyPostalAddressView address = new AxdEntity_DirPartyPostalAddressView();
            address.LocationName = "Location Name";
            address.Street = "Street name";
            address.City = "ciyt name";
            address.State = "state name";
            address.CountryRegionId = "country name";
            address.ZipCode = "90211";
            address.Roles = "Address roles";

            ////Create an electronic address
            AxdEntity_DirPartyContactInfoView electronicAddress = new AxdEntity_DirPartyContactInfoView();
            electronicAddress.LocationName = "Contact Email";
            electronicAddress.Type = AxdEnum_LogisticsElectronicAddressMethodType.Email;
            electronicAddress.TypeSpecified = true;
            electronicAddress.Locator = "name@company.com";
            electronicAddress.Roles = "company";

            ////Add the addresses to the party record and the party to the CustTable record
            custTable.DirParty = new AxdEntity_DirParty_DirPartyTable[1] { party };
            custTable.DirParty[0].DirPartyPostalAddressView = new AxdEntity_DirPartyPostalAddressView[1] { address};
            custTable.DirParty[0].DirPartyContactInfoView = new AxdEntity_DirPartyContactInfoView[1] { electronicAddress };

            //Add the CustTable record to the Customer entity
            customer.CustTable = new AxdEntity_CustTable[1] { custTable };

            //Create the customer
            EntityKey[] key = null;
            key = proxy.create(context, customer);

        }

    }
}

Wednesday, 17 December 2014

Table collections in AX 2012


Dynamics Ax Table collections & Virtual company
If using more than one company, sometimes, it will be useful to share data from tables with general information, like, tables storing data like zip codes and country codes. The most basic way to share data from a table among all companies is to set the table property SaveDataPerCompany to No.
This will merge data for the table and make the data accessible from all companies. In practice, the kernel will delete the system field dataAreaId for the table.
Another way to sharing data without having to change any settings in the existing tables is by using Table Collections. A table collection is just a template for tables to be shared by any number of companies and Table collections shared using a virtual company.

The form SysDataAreaVirtual is used to define virtual companies. Virtual company is a term used for sharing table collections among a set of companies and does not exist in reality, and therefore, you cannot switch to a virtual company like any normal company.

When using TC for setup tables (like customer groups), setting up a VC will be easy. But, if you are going to share data from main tables (like the inventory table), you should do more investigation as you cannot only share the table InventTable. You must include all tables which are related to InventTable.

Note: Before creating a VC you should export data for the tables used in the table collection, as existing data will be deleted from these tables when added to a virtual company.

Virtual Company setup:

Step 1: Create Table Collection:
Decide which tables you want to share and create a Table collection for these functionally related tables. For example; if you want to share 'Global Address Book' across companies then you can utilize the existing table collection "DirPartyCollection".

To create a table collection, go to AOT\Data Dictionary\Table Collections and on right click select "New Table Collection", then just drag your required tables in this collection.

Step 2: Create Virtual Company, configure/attach normal companies and table collection:
Create a virtual company that will hold the shared data for normal companies.
Note: Before doing the below steps, make sure you are the Ax administrator and the only user online.
1.       Go to Administration > Setup > Virtual company accounts, and create a virtual company.

2.      Decide which companies needs to share data and attach those normal companies with this virtual company.

3.      Attach the table collection with this virtual company and save form.

Your Ax client will re-start and you are done with setting up the virtual company account.

Now, when you have virtual company in place, all new data will be saved in this virtual company. Only companies attached to the virtual company can use this shared data. All other companies which are not attached will work normally, these companies will continue to read/write data as per company bases.

How to move existing data to virtual company?
When you setup a new virtual company, Ax does not move data automatically from normal company to virtual company. This is done by system administrator manually.

There are many ways to do this data move, let’s see only two such approaches here.
Approach 1: Ax Import / Export
This is standard Ax approach.
1.        Manually export existing normal company data from Ax.
2.        Remove duplicate records from this exported data set.
3.        Delete exported data from normal companies.
4.        Import the exported data back in Ax, while logged into one of the participating companies.
5.        Create records deleted in point 2 again in Ax using your logic. How you want to handle duplicate? For example, if you have customer 'Customer' in more than one normal company, what you want to do with this?
Approach 2: Direct SQL
Use this approach if you have good knowledge about SQL queries and Ax table structures/relationships. Below are steps you can follow.
1.        All Ax tables store data as per company unless otherwise specified. For this, Ax uses a special field called DataAreaId. In case of virtual company, it does not matter from which normal company you log-in, it is always the virtual company id which is stored in DataAreaId field of shared tables.
2.        Ax also assigns a unique 64bit number to each record in table. For this, Ax uses a special field called RecId. This RecId is unique in the table and is generated by Ax when you insert a new record in Ax. It is not related to DataAreaId / Company.
3.        For unique records between all participating normal companies, update the DataAreaId to the virtual company id.
For duplicate records, create them again in Ax using some Ax job or Ax import/export technique.

Best Practices for Troubleshooting Application Issues in D365 and Power Platform

When facing application issues, it’s important to systematically troubleshoot before reaching out for support.  Follow these steps to ensure...