Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Wednesday, October 30, 2013

Job / class /code to import the CSV / Excel file in to Vendor table in Dynamic AX 2012

Hi,

1.Prepare the CSV (If it was excel convert ti CSV)  file containing following fields in same order as below
account 
EnglishName 
English 
SearchName 
Invoice 
account 
VendorGroup 
Terms of payment 
Currency 
One-time supplier 
Country/region 
Delivery terms 
Mode of delivery 
Misc. charges group 
Buyer group

2. Create a class using below codes and just run by using |> run button or F5


/**********************************************/
public class VendorMasterImport extends RunBase
{
    CommaIo                     csvFile;
    Filename                    filename;
    DialogField                 dialogFilename;
    #define.CurrentVersion(2)
    #localmacro.CurrentList
    filename,
    insertIncorrectRecords,
    #endmacro
    #localmacro.ListVersion1
    filename,
    insertIncorrectRecords
    #endmacro
    #File
}
/************************************************/
public Object dialog()
{
    DialogRunbase       dialog = super();
    ;
    dialogFilename  = dialog.addField(extendedTypeStr(FilenameOpen));
    dialogFilename.value(filename);
    dialog.filenameLookupFilter(["All files", #AllFiles]);
    return dialog;
}
/**********************************************/
public boolean getFromDialog()
{
    filename                = dialogFilename.value();
    return true;
}
/**********************************************/
void run()
{
    //CommaTextIO                             csvFile;
    container                               readCon;
    counter                                 icount,inserted;
    Dialog                                  dialog;
    DialogField                             dfFileName;
    DirPartyRecId                           partyRecId,contactPartyRecid;
    Name                                    name,contactName;
    VendTable                               vendtable;
    str                                     contactperson;
    DirPartyPostalAddressView               addressView;
    DirPartyContactInfoView                 contactView;
    ContactPerson                           contactpersonTable;
    LogisticsElectronicAddressMethodType    enumType;
    DirContactPersonsService                dirContactPersonsService;
    DirContactPersons                       dirContactPersons;
    DirContactPersons_ContactPerson         dirContactPersons_ContactPerson;
    DirContactPersons_Person                dirContactPersons_Person;
    DirContactPersons_PersonName            dirContactPersons_PersonName;
    AifEntityKeyList                        aifEntityKeyList, aifEntityKeyList_DirContactPerson;
    str                                     fName, mName, lName;
    VendAccount                             vendorAccount;
    DirParty                                dirParty;
    LogisticsPostalAddress                  address;
    LogisticsElectronicAddress              logisticsElectronicAddress;
    BinData                                 binData;
    str                                     stringImage;
    LogisticsAddressStateID                 stateId;
    str                                     accountnum,accountName,vendgroup,currency,dlvmode,paymtermid,countryid,street,city,mobile,fax,email,zipcode,pobox,phone;
    CustInvoiceAccount  invoiceaccount;
    LogisticsAddressCountryRegionId  countryregion;

    NoYes               ontimecustomer;
    CustDlvTermId       termid;
    CustMarkupGroupId   chargegroup;
    ItemBuyerGroupId    buyergroupid;
    ;

    csvFile = new CommaIO(filename, 'r');
    try
    {
        if (csvFile)
        {
           // ttsbegin;
            readCon = csvFile.read();
            while (csvFile.status() == IO_Status::OK)
            {
                readCon = csvFile.read();
                if(readCon)
                {
                icount++;
                accountnum = conPeek(readCon,1);
                accountName = conPeek(readCon,2);
                    name = conPeek(readCon,3);
                invoiceaccount = conPeek(readCon,4);
                vendgroup = conPeek(readCon,5);
                paymtermid = conPeek(readCon,6);
                currency = conPeek(readCon,7);
                ontimecustomer = conPeek(readCon,8);
                countryregion= conPeek(readCon,9);
                termid=conPeek(readCon,10);
                dlvmode = conPeek(readCon,11);
                chargegroup = conPeek(readCon,12);
                    buyergroupid = conPeek(readCon,13);
                if(!name)
                break;
                partyRecId = DirPartyTable::createNew( DirPartyType::Organization, name).RecId;
                vendtable.clear();
                vendtable.initValue();
                vendtable.Party = partyRecId;
                vendtable.AccountNum = accountnum;
                vendtable.VendGroup  = vendgroup;
                vendtable.Currency   = currency;
                vendtable.DlvMode    = dlvmode;
                vendtable.PaymTermId   = paymtermid;
                vendtable.OneTimeVendor   =  ontimecustomer;
                vendtable.DlvTerm =termid;
                vendtable.DlvMode = dlvmode;
                vendtable.MarkupGroup = chargegroup;
                vendtable.InvoiceAccount = invoiceaccount;
                vendtable.ItemBuyerGroupId  = buyergroupid;
                if(contactperson != '')
                {
                    contactname = ContactPerson;
                    ContactPerson::findOrCreateNameParty(partyRecId,contactname);
                }
               vendtable.insert();
                stateId = subStr(stateId,1,25);
                address.PostBox = strLRTrim(PoBox);
                address.CountryRegionId = strLRTrim(Countryid);
                address.State = stateId;
                address.ZipCode = strLRTrim(ZipCode);
                address.Street  = strLRTrim(Street);
                address.county = countryregion;
                address.City    = strLRTrim(City);
                addressView.LocationName = name;
                addressView.IsPrimary = NoYes::Yes;
                addressView.Party = partyRecId;
                addressview.initFromPostalAddress(address);

                DirParty = DirParty::constructFromPartyRecId(addressView.Party );
                DirParty.createOrUpdatePostalAddress(addressView);

                inserted++;
                }
            }
        }
        icount--;//Remove header recount from total record count
    }
    catch(Exception::Error)
    {
        info(strFmt("%1 %2",Exception::Error,icount));
    }
}
/**********************************************/
static void main(Args  args)
{
    VendorMasterImport        VendorMasterImport;
    ;
    VendorMasterImport =  new VendorMasterImport();
    if(VendorMasterImport.prompt())
    {
        VendorMasterImport.run();
    }
}
/*************************************************/
3. Now you will find a browser like this.

4.Select CSV file and proceed.

Regards,

Tuesday, October 29, 2013

Code / job to import CSV / Excel to CustTable in Dynamic AX 2012

1.Prepare the CSV (If it was excel convert ti CSV)  file containing following fields in same order as below
Customer account
English Name
English Search Name
Invoice account
Customer group
Terms of payment
Currency
One-time customer
Country/region
Delivery terms
Mode of delivery
Misc. charges group
Language

2. Create a class using below codes and just run by using |> run button or F5

public class CustomerMasterImport extends RunBase
{
    CommaIo                     csvFile;
    Filename                    filename;
    DialogField                 dialogFilename;
    #define.CurrentVersion(2)
    #localmacro.CurrentList
    filename,
    insertIncorrectRecords,
    #endmacro
    #localmacro.ListVersion1
    filename,
    insertIncorrectRecords
    #endmacro
    #File
}
/*********************************************/
public Object dialog()
{
    DialogRunbase       dialog = super();
    ;
    dialogFilename  = dialog.addField(extendedTypeStr(FilenameOpen));
    dialogFilename.value(filename);
    dialog.filenameLookupFilter(["All files", #AllFiles]);
    return dialog;
}
/********************************************/
public boolean getFromDialog()
{
    filename                = dialogFilename.value();
    return true;
}
/*******************************************/
void run()
{
    //CommaTextIO                             csvFile;
    container                               readCon;
    counter                                 icount,inserted;
    Dialog                                  dialog;
    DialogField                             dfFileName;
    DirPartyRecId                           partyRecId,contactPartyRecid;
    Name                                    name,contactName;
    CustTable                               vendtable;
   // VendTable                               vendtable;
    str                                     contactperson;
    DirPartyPostalAddressView               addressView;
    DirPartyContactInfoView                 contactView;
    ContactPerson                           contactpersonTable;
    LogisticsElectronicAddressMethodType    enumType;
    DirContactPersonsService                dirContactPersonsService;
    DirContactPersons                       dirContactPersons;
    DirContactPersons_ContactPerson         dirContactPersons_ContactPerson;
    DirContactPersons_Person                dirContactPersons_Person;
    DirContactPersons_PersonName            dirContactPersons_PersonName;
    AifEntityKeyList                        aifEntityKeyList, aifEntityKeyList_DirContactPerson;
    str                                     fName, mName, lName;
    VendAccount                             vendorAccount;
    DirParty                                dirParty;
    LogisticsPostalAddress                  address;
    LogisticsElectronicAddress              logisticsElectronicAddress;
    BinData                                 binData;
    str                                     stringImage;
    LogisticsAddressStateID                 stateId;
    str                                     accountnum,accountName,vendgroup,currency,dlvmode,paymtermid,countryid,street,city,mobile,fax,email,zipcode,pobox,phone;
    //
    CustInvoiceAccount  invoiceaccount;
    LogisticsAddressCountryRegionId  countryregion;

    NoYes               ontimecustomer;
    CustDlvTermId       termid;
    CustMarkupGroupId   chargegroup;
    ItemBuyerGroupId    buyergroupid;
    ;

    csvFile = new CommaIO(filename, 'r');
    try
    {
        if (csvFile)
        {
            readCon = csvFile.read();
            while (csvFile.status() == IO_Status::OK)
            {
                readCon = csvFile.read();
                if(readCon)
                {
                icount++;
                accountnum = conPeek(readCon,1);
                accountName = conPeek(readCon,2);
                name = conPeek(readCon,3);
                invoiceaccount = conPeek(readCon,4);
                vendgroup = conPeek(readCon,5);
                paymtermid = conPeek(readCon,6);
                currency = conPeek(readCon,7);
                ontimecustomer = conPeek(readCon,8);
                countryregion= conPeek(readCon,9);
                termid=conPeek(readCon,10);
                dlvmode = conPeek(readCon,11);
                chargegroup = conPeek(readCon,12);
                if(!name)
                break;
                partyRecId = DirPartyTable::createNew( DirPartyType::Organization, name).RecId;
                vendtable.clear();
                vendtable.initValue();
                vendtable.Party = partyRecId;
                vendtable.AccountNum = accountnum;
                vendtable.CustGroup  = vendgroup;
                vendtable.Currency   = currency;
                vendtable.DlvMode    = dlvmode;
                vendtable.PaymTermId   = paymtermid;
                vendtable.OneTimeCustomer   =  ontimecustomer;
                vendtable.DlvTerm =termid;
                    vendtable.DlvMode = dlvmode;
                   vendtable.MarkupGroup = chargegroup;
                    vendtable.InvoiceAccount = invoiceaccount;
                    vendtable.PartyCountry = countryregion;
                if(contactperson != '')
                {
                    contactname = ContactPerson;
                    ContactPerson::findOrCreateNameParty(partyRecId,contactname);
                }
               vendtable.insert();
                stateId = subStr(stateId,1,25);
                address.PostBox = strLRTrim(PoBox);
                address.CountryRegionId = strLRTrim(Countryid);
                address.State = stateId;
                address.ZipCode = strLRTrim(ZipCode);
                address.Street  = strLRTrim(Street);
                address.county = countryregion;
                address.City    = strLRTrim(City);
                addressView.LocationName = name;
                addressView.IsPrimary = NoYes::Yes;
                addressView.Party = partyRecId;
                addressview.initFromPostalAddress(address);

                DirParty = DirParty::constructFromPartyRecId(addressView.Party );
                DirParty.createOrUpdatePostalAddress(addressView);
         inserted++;
                }
            }
        }
        icount--;//Remove header recount from total record count
    }
    catch(Exception::Error)
    {
        info(strFmt("%1 %2",Exception::Error,icount));
    }
}
/***********************************************/
static void main(Args  args)
{
    CustomerMasterImport        VendorMasterImport;
    ;
    VendorMasterImport =  new CustomerMasterImport();
    if(VendorMasterImport.prompt())
    {
        VendorMasterImport.run();
    }
}
/*********************************************/
3. Now you will find a browser like this.

4. Select your CSV file and proceed.

Regards,

Thursday, October 24, 2013

Creating & Using the find() methods in Dynamic AX 2012

Hi,
1. Create a table,
2. Use the 2 EDTs and make it one as index as unique by property AllowDuplicates : NO
3. Create a find method in the table using below code and patten

static TableName find(UsedEDT _UsedEDT ,
                       boolean          _forUpdate = false,
                       ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)
{
    TableName  tableName ;

    if (_UsedEDT)
    {
        if (_forUpdate)
        {
            tableName .selectForUpdate  (_forUpdate);
            if (_concurrencyModel != ConcurrencyModel::Auto)
                tableName .concurrencyModel(_concurrencyModel);
        }
        tableName .selectLocked     (_forUpdate);

        select firstonly tableName
            index hint UsedEDTIndex
            where tableName.UsedEDT == _UsedEDT ;
    }

    return     tableName ;
}
/************************Using the find method **********************/
Using the display method with find() we can get that value by using below codes in the table.
display Name name()
{
    return TableName::find(this.UsedEDT).name();
}

Vertical splitter in forms (Dynamic AX 2012)

Hi,

1. Create a group inside the main group
note: between the two groups

2. In property window of that group
Autodeclaration  :Yes
Style  : SplitterVerticalContainer

3.In the class declaration of that form use below code
public class FormRun extends ObjectRun
{
    SysFormSplitter_X    m_vSplitter;
}

4. In the init method of the form use below code pattern

public void init()
{
    ;
    super();
    m_vSplitter = new SysFormSplitter_X(vSplitter, gridContainer, element);
}


Tuesday, October 22, 2013

Display message when empty report "No data found in SSRS"

Hi,

In the property window os Visual studio (SSRS) check 'NoRowsMessage' property for tablix. You can set this property to show a custom message when no row is returned.

NORowsMessage = "No data available for current filter selection" //user defined msg that is to be displayed
You can also specify the specific font style like size, color, format etc.

Add a text box with expression =IIF(Count(<SomeId Field>,"DataSet1")=0,"No Data Returned", nothing)

 Or

set the visibility of this textbox as =IIF(Count(<SomeId Field>,"DataSet1")=0,False,True)

In the table header (header fields), use expression for each of the column headers to Set the visibility to false so that the end user won’t be able to see the table header when there is no data.


AX 2012 Help Server error: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Hi,

To resolve this issue, run the following command line: 

aspnet_regiis.exe /iru
The Aspnet_regiis.exe file can be found in one of the following locations:
%windir%\Microsoft.NET\Framework\v4.0.30319
%windir%\Microsoft.NET\Framework64\v4.0.30319 (on a 64-bit computer)


HTTP Error 500.24 – Internal Server Error + HELP SERVER ERROR AFTER INSTALLING ON AX 2012 + ERROR – Unable to contact the server

Hi,

This error may arises at any of this name for same reason.

HTTP Error 500.24 – Internal Server Error,
The Location of the help server has not been specified.
ERROR – Unable to contact the server etc...
HTTP Error 500.24 – Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

Detailed Error Information
Module
ConfigurationValidationModule
Notification
BeginRequest
Handler
svc-Integrated
Error Code
0×80070032
Requested URL
Physical Path
C:\inetpub\wwwroot\DynamicsAX6HelpServer\HelpService.svc
Logon Method
Not yet determined
Logon User
Not yet determined
 Solution:
  1. Check that Directory browsing is enabled(IIS MANAGER>SITES>DIRECTORY BROWSING(DOUBLE CLICK AND ENABLE IT)
  2. Go to Ax 2012>System administration > setup>system>Help system parameters
(check the location should be as
  1. Also when you browse the site in IIS manager it will tell you ASP.NET 4.0 check for Integrated pipeline mode
    1. Check the below criteria it should be the same
    2. IIS>Application Pools>
    3. ASP.NET4.0                                  V4.0       CLASSIC
    4. ASP.NET4.0 CLASS                        V4.0       CLASSIC
    5. CLASSIC .NET APPLICATION           V2.0       CLASSIC
    6. DEFAULT APP POOL                       V2.0       INTEGRATED
    7. DYNAMICS AX HELP SERVER          V4.0       INTEGRATED(Version will be 2.0 change to 4.0 and check)  pls keep in mind DynamicAX  HelpSVC >ASP.NET IMPERSONATION SHOULD BE DISABLE(DON’T ENABLE)


Installation of Help Server AX2012

Microsoft Dynamics AX Help is a client and server based system that distributes and displays documentation.
1.       The Help client is the Help viewer application that requests and displays documentation and gets installed with the Microsoft Dynamics AX client application.
2.       The Help server responds to the Help viewer request for documentation. In addition, the Help server stores the files that contain the Help documentation.
Important: This Server-client Help system does not supply Help documentation for Enterprise Portal. You will have to install Enterprise Search to support help documentation for EP.

Other information about Ax 2012 Help server which is good to know:
ü  Typically, you can initiate a help request from either the client or developer workspace by pressing F1 /button / via command.
ü  The client identifies the Help topic to retrieve. To identify the documentation for the form from where Help is initiated, the documentation has an ID property that has the same value as the ID of the form.
ü  The client retrieves the URL of the Help web service. The first time that you request help, the client contacts the AOS to retrieve the URL of the help web service. The client then caches the URL and uses the cached URL for additional help requests.
ü  The client calls the Help viewer. If the Help viewer is not running, the viewer is started. The call to the Help viewer includes the URL of the help server and the ID of the form.
ü  URL can be updated/modified under path AX2012 > System Administration > Setup > System > Help system parameters.

How to Install the Help server:
1.       Start Microsoft Dynamics AX Setup. Under Install, select Microsoft Dynamics AX components.Advance through the initial wizard pages.
2.       On the Select installation type page, click Custom installation, and then click Next.On the Select components page, select Help Server, and then click Next.


3.       Check for prerequisites, When no errors remain, click Next.
4.       On the Connect to an AOS instance page, enter the name of the computer that is running AOS and other port. Click Next.Note that, If you entered AOS information for other Microsoft Dynamics AX components that you have installed on this computer, this screen is not displayed.
5.       On the Configure a Web site for Help Server page, select the web site that you have chosen to host the Help server. Verify that the location of the physical directory for the web site is displayed. Click Next.


6.       On the Specify the Help Server account page, enter a domain user account and password.This account must be the same as the .NET Business Connector proxy account for the AOS, and it must be a user in Microsoft Dynamics AX. This should be a service account that does not expire. Click Next.
7.       On the Language and content selection page, select the Help languages and content types to install. EN-US must be installed, and is checked by default. Click Next.
8.       On the Prerequisite Validation page, resolve any errors.
One possible error which you might observe when you have SharePoint / Enterprise portal already installed in the machine is shown below:




Error: Web site (Help Server) is shown because the Default web site is not started. And this could be because SharePoint installation has taken over the Port 80 and kicked off the Default web site.

Solution: Go to IISManager (inetmgr) and then Edit bindings for the Default site to change the port number from 80 to something else (say 81).
After doing so, you can start the Website. This should resolve the issue shown above.





9.       When no errors remain, click Next.
10.     On the Ready to install page, click Install.After the installation is complete, click Finish to close the wizard.
After the Microsoft Dynamics AX Help files are installed, they must be indexed by Windows Search Service before you can view them. Depending on system load and the number of files, it may take up to an hour for indexing to finish.
More information on how to Install the help server [AX 2012]

Unable to find appropriate service endpoint information in the configuration object + An error occurred during setup of Reporting Services extensions.

Error:  "An occurred during setup of Reporting Services extensions. Reason: Unable to find appropriate service endpoint information in the configuration object"

Reason: BIServices port is not deployed.
Resolution:
ü  Activate inbound ports BIServices (System Administration > Setup > Services and AIF > Inbound ports)
ü  Delete the WCFCONFIG entry in registry under the Dynamics AX current user hive key (HKEY_CURRENT_USER\Software\Microsoft\Dynamics\6.0\Configuration\Orig)
ü  Restart the box
ü  Try installation again.  If fails then continue with
ü  Make the BC proxy user a local admin on the SRS box.
ü  Redeploy BIServices services: AOT > ServiceGroups > Right Click BIServices and deploy.
Environment Details - Dynamics AX 2012 R2

Explanation: Reporting services Extension is a service that occupies a port in Dynamics AX 2012. Whenever you use Reporting services extension you need to activate a port BIServices

Steps for Registry:

1.     Click Start, and then click Run.
2.     In the Open box, type cmd and then press ENTER.
3.     In the Open box, type regedit and then press ENTER.
4.  Locate the following subkey in the registry: 
         HKEY_CURRENT_USER\Software\Microsoft\Dynamics\6.0\Configuration\Orig
    5.  Delete the file "WCFCONFIG" file


FileNameSplit() to slip the Directory, file name and extension in D365 FnO

 Hi,     /// <summary>     /// Validate the Fileformat     /// </summary>     /// <param name = "filepath">FileP...