Get Attention Name from a Debtor

Forum for .PHP developers using the E-conomic API.
Exchange your ideas, tip and tricks using the API.
Best Practices

Get Attention Name from a Debtor

Postby thauser » Thu Nov 24, 2011 10:58 pm

Hi!

I´m trying to list my Debtors - which I can do without problems;

Code: Select all
// Fetch list of all debtors.
                    $debtorHandles = $client->Debtor_GetAll()->Debtor_GetAllResult->DebtorHandle;
                    $debtorDataObjects =$client->Debtor_GetDataArray(array('entityHandles' => $debtorHandles))->Debtor_GetDataArrayResult->DebtorData;
               
                            foreach ($debtorDataObjects as $i => $debtorData) {
               
                            $ekundeNr = $debtorData->Number;
                            $ekundeNavn = utf8_decode($debtorData->Name);
                            $ekundeAdresse = utf8_decode($debtorData->Address);
                            $ekundePost = utf8_decode($debtorData->PostalCode);
                            $ekundeBy = utf8_decode($debtorData->City);
                            $ekundeEan = $debtorData->Ean;
                            $ekundeAtt = $debtorData->AttentionHandle->Id;
                             }


Then I get the ID (eg. 268) from then AttentionHande ($ekundeAtt).

Now I would like to know the NAME of Attention with ID (eg. 268).

Help ;)

----

Also, I would like to get the NAMES of all the Attentions related to a customer number...

I have no idea how to...


BR Thauser
-
thauser
 
Posts: 6
Joined: Thu Sep 15, 2011 9:08 pm

Re: Get Attention Name from a Debtor

Postby Christian Estrup » Sat Nov 26, 2011 9:21 am

Hi thauser,

Attentions are DebtorContact entities, so if you use the handle to look up the relevant DebtorContact, you should be able to pick up the name.


Best regards,
Christian Estrup
Chief Architect

Image
Online accounting
User avatar
Christian Estrup
 
Posts: 245
Joined: Tue Jun 09, 2009 6:37 pm

Re: Get Attention Name from a Debtor

Postby thauser » Sat Nov 26, 2011 1:57 pm

Hi Christian,

Got it - but it boosts the runtime from 5s to 70s...

Think I will have to live with that.


BR Thauser
-
thauser
 
Posts: 6
Joined: Thu Sep 15, 2011 9:08 pm

Re: Get Attention Name from a Debtor

Postby Christian Estrup » Tue Nov 29, 2011 5:18 am

Hi Thauser,

You can optimize that greatly by pulling all DebtorContacts via .GetAll(), followed by .GetDataArray(), and then do a lookup on that.

- pretty much the same as described in this (admittedly .NET) example: http://techtalk.e-conomic.com/improving-api-performance-beyond-data-classes/.


Best regards,
Christian Estrup
Chief Architect

Image
Online accounting
User avatar
Christian Estrup
 
Posts: 245
Joined: Tue Jun 09, 2009 6:37 pm


Return to PHP



cron