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
Please advise how can I get phone, cell/mobile phone of contact of customer in SalesInvoice Report.
Thank you so much for your help! :D
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)); } }
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); }
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.
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)); }
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156