Tuesday 8 November 2016

Get company address through code in AX.

static void getCompanyAddress(Args _args)
{
    CompanyInfo companyInfo;
    DirPartyPostalAddressView postalAddressView;
    ;

    companyInfo = companyInfo::find();

    select firstFast postalAddressView
        where postalAddressView.Location == companyInfo.PrimaryAddressLocation;

    info(companyInfo.Name+ "," +postalAddressView.Address);
}

Get company information in AX 2012 using X++.

static void getCompanyInfo(Args _args)
{
    CompanyInfo companyInfo;
    Description tel,fax,Email,URL;
    ;

    companyInfo = companyInfo::find();

    Email = LogisticsElectronicAddress::findRecId(companyInfo.PrimaryContactEmail).Locator;
    fax = LogisticsElectronicAddress::findRecId(companyInfo.PrimaryContactFax).Locator;
    tel = LogisticsElectronicAddress::findRecId(companyInfo.PrimaryContactPhone).Locator;
    url = LogisticsElectronicAddress::findRecId(companyInfo.PrimaryContactURL).Locator;
 
    info(strFmt("Email - %1, Fax - %2, Tel - %3, URL - %4",Email,fax,tel,URL));
}

Change date format in AX



static void dateFormat(Args _args)
{
    info(strFmt("Today date is " +date2str(today(),123,DateDay::Digits2,DateSeparator::Hyphen,
        DateMonth::Short,DateSeparator::Hyphen,DateYear::Digits4)));
}