Get all contact Information of any particular customer from table in a Job

Hi all,

I have a customer named ‘Test-1’, when I double click on the person in ‘All Customers’ form, we get another Form showing us the details of this particular customer. There is a FastTab called Contact Information where we set Information like Phone (Primary), Email, Fax, URL and Phone for customers.

I want to display the values of these five contact information on infolog.

please suggest, how can I do that ?

when I personalize the ‘contact number/address’ field in the form, It shows that It is coming from a table called LogisticsElectronicAddress table. I have checked that table. There is a field called ‘Locator’ in that table which stores all these values which I want to display on infolog in a job.

The problem is I want to show these values for any particular customer which I will present as parameter. The customers are stored in CustTable table. There is no relation between these two tables, so how will I fetch right data from LogisticsElectronicAddress table against a particular customer from CustTable.

How will the join be performed in select statement in the Job. I need x++ code.

Look at how the information is checked - for example - by email() method on CustTable:

display Email email()
{
	LogisticsElectronicAddress electronicAddress;

	electronicAddress = DirParty::primaryElectronicAddress(this.Party, LogisticsElectronicAddressMethodType::Email);
	if (!electronicAddress)
	{
		electronicAddress = DirParty::getElectronicAddressForPartyPostalAddress(this.Party, LogisticsElectronicAddressMethodType::Email);
	}

	return electronicAddress ? electronicAddress.Locator : '';
}

If you then look into DirParty::primaryElectronicAddress(), you’ll see that the the electronic address is obtained in this way:

LogisticsElectronicAddress  logisticsElectronicAddress;
DirPartyTable dirPartyTable;

select firstonly logisticsElectronicAddress
	exists join dirPartyTable
		where dirPartyTable.PrimaryContactEmail == logisticsElectronicAddress.RecId
		&& dirPartyTable.RecId == _partyRecId;

Are you able to write your code based on this information, or do you need anything else?

Thanks for reply Martin.

Yes, I need to ask something.

Can you please explain what this particular line of code is doing

electronicAddress = DirParty::primaryElectronicAddress(this.Party, LogisticsElectronicAddressMethodType::Email);

I already know that LogisticsElectronicAddressMethodType is an enum used in the Type field of LogisticsElectronicAddress table. What is DirParty::primaryElectronicAddress fetching here and from which table ? what is primaryPostalAddress ? I checked DirPartyTable. There is no such field or method with this name in that table. please explain as I really want to know about it.

How can I use above snippets in my favour ?

Are you suggesting that I should create methods similar to email() in CustTable. I have checked in there. There are already some methods available in custtable like phone, email and url, but there is no methods available for fax and phone (non primary). The phone() method in custtable will get primary phone number of the customer.

About the second code snippet, I would like to know what to put in place of _partyRecId ? I want to give customer as parameter like ‘US-002’ and it will return contact information for this particular customer.

This line:

electronicAddress = DirParty::primaryElectronicAddress(this.Party, LogisticsElectronicAddressMethodType::Email);

doesn’t do much - it simply calls a method and assing a result to a variable. Specifically, it finds a record of LogisticsElectronicAddress table for the given party ID and the type of electronic address (Email in this case). In other words, it finds details of the primary email address of a party. A party is a generic concept covering both persons and companies.

I even showed you simplified content of primaryElectronicAddress() in my previous reply. It finds a record in DirPartyTable for the given PartyId, then takes the value from PrimaryContactEmail field (which is a RecId of LogisticsElectronicAddress table) and find the LogisticsElectronicAddress record.

No, I’m not saying that you should create methods similar to email(). I’m explaining you how the relations work and showing how you can find such information by yourself.

Regarding your last sentence, please look again at the I showed you. You can see that it uses this.Party field, and it’s inside a method of CustTable, therefore it’s the Party field from CustTable.