Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
Posted on by 880

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

  • SadiqQ Profile Picture
    SadiqQ 435 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.

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

    Thank you so much for your help! :D

  • Verified answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 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
    Momochi 880 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);
    
    }


  • Momochi Profile Picture
    Momochi 880 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.

  • Verified answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 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));
    }


    
    

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans