web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get current company's Contact Information(Type, Phone Number, PostBox)

(0) ShareShare
ReportReport
Posted on by 1,013

Hello awesome community! I'm new to AX development and i'm working on a report using DP class that requires me to show current company's information (Address, Type, Phone, Post Box).

There are multiple codes in the internet, tried some but unfortunately I couldn't get the information.

If possible can you give me a simple code that shows these information? 

I appreciate your help and thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: How to get current company's Contact Information(Type, Phone Number, PostBox)

    Hi,

    You can use following code to get details from companyInfo.

    static void AXC_CompanyInfo(Args _args)
    {
        CompanyInfo companyInfo;
        LogisticsPostalAddress address;
        
        companyInfo = CompanyInfo::find();
        address = companyInfo.postalAddress();
        
        info(strFmt("Address: %1, Type: %2, Phone: %3, POBox: %4", address.Address, companyInfo.type(), companyInfo.phone(), address.ZipCode));
    }


    
    
  • Momochi Profile Picture
    1,013 on at
    RE: How to get current company's Contact Information(Type, Phone Number, PostBox)

    Thanks Chaitanya for your help, your code helped me get the address!

    But there is a small problem left that I don't understand.

    when I use CompanyInfo::find().phone();

    It does not show the phone number, it shows nothing.

    but if I went to "Legal Entities" Form and make the phone number as primary, and edit the code to :

    CompanyInfo::find().primaryPhone();

    it does work and shows the phone number.

    is there a way that can show the phone number without it being necessarily a primary phone? I believe it is as you stated:

    CompanyInfo::find().phone();

    but somehow it does not work.

    Thanks.

  • Momochi Profile Picture
    1,013 on at
    RE: How to get current company's Contact Information(Type, Phone Number, PostBox)

    Thank you Mr. Sukrat for your help!

    I opened SalesInvoiceDP init method as you stated but couldn't find the code that retrieves company's related information. I'm sorry maybe because i'm still a beginner.

    Here is the code I found in "SalesInvoiceDP" init method:

    /// <summary>
    /// Initializes required data before it starts to process the report.
    /// </summary>
    /// <param name="_custInvoiceJour">
    /// A <c>CustInvoiceJour</c> record that has the sales invoice header information.
    /// </param>
    /// <remarks>
    /// This method will initialize some variables which will be used during processing the report.
    /// </remarks>
    protected void init(CustInvoiceJour _custInvoiceJour)
    {
        super(_custInvoiceJour);
    
        if (_custInvoiceJour.creditNote())
        {
            isInvoiceCreditNote = true;
            formLetterRemarks = FormLetterRemarks::find(_custInvoiceJour.LanguageId,FormTextType::SalesCreditNote);
        }
        else
        {
            formLetterRemarks = FormLetterRemarks::find(_custInvoiceJour.LanguageId,FormTextType::SalesInvoice);
        }
    
        this.initInventDimData();
    
        cachedTaxableBalanceEuro = _custInvoiceJour.taxableBalanceEuro(this.tmpTaxWorkTrans(_custInvoiceJour));
        cachedTaxFreeBalanceEuro = _custInvoiceJour.taxFreeBalanceEuro(this.tmpTaxWorkTrans(_custInvoiceJour));
        cachedTaxableBalance    = _custInvoiceJour.taxableBalance(this.tmpTaxWorkTrans(_custInvoiceJour));
        cachedTaxFreeBalance    = _custInvoiceJour.taxFreeBalance(this.tmpTaxWorkTrans(_custInvoiceJour));
        cachedCashDiscEuro      = _custInvoiceJour.amountCur2Euro(_custInvoiceJour.CashDisc);
    
        //<GEEU>
        if (conFind(#easternEuropeAll, isoCountryCode))
        {
            cachedTaxFreeBalanceMST = _custInvoiceJour.taxFreeBalanceMST(this.tmpTaxWorkTrans(_custInvoiceJour));
            cachedTaxableBalanceMST = _custInvoiceJour.taxableBalanceMST(this.tmpTaxWorkTrans(_custInvoiceJour));
            cachedEuroExchangeRate  = this.getEuroExchangeRate(_custInvoiceJour);
            cachedNetAmountMST      = _custInvoiceJour.netAmountMST();
        }
        //<GEEU>
    
        this.initGiro(_custInvoiceJour);
    
    }


  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: How to get current company's Contact Information(Type, Phone Number, PostBox)

    Hi,

    You can use following code to get the phone number(not primary) specified on companyInfo. I used only select statement, to get all the phone numbers please use while-select loop.

    static void AXC_CompanyPhone(Args _args)
    {
        DirPartyLocation            dirPartyLocation;
        LogisticsElectronicAddress  electronicAddress;
        CompanyInfo                 companyInfo;
        
        companyInfo = companyInfo::find();
        
        select dirPartyLocation
            where dirPartyLocation.Party == companyInfo.RecId
            &&  dirPartyLocation.IsPostalAddress == NoYes::No
            join electronicAddress
            where electronicAddress.Location == dirPartyLocation.Location
            && electronicAddress.Type == LogisticsElectronicAddressMethodType::Phone;
        {
            info(strFmt("Description: %1, Contact number/address: %2",  electronicAddress.Description, electronicAddress.Locator));
        }
    }
  • Momochi Profile Picture
    1,013 on at
    RE: How to get current company's Contact Information(Type, Phone Number, PostBox)

    Thank you so much for your help! :D

  • SadiqQ Profile Picture
    437 on at
    RE: How to get current company's Contact Information(Type, Phone Number, PostBox)

    Please advise how can I get phone, cell/mobile phone of contact of customer in SalesInvoice Report.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans