API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Debtor_FindByName Debtor_GetDataArray

0

These two lines works very well, I get all the given information from all debitors. 

$debtorHandles = $client->Debtor_GetAll()->Debtor_GetAllResult->DebtorHandle;
$debtorDataObjects = $client->Debtor_GetDataArray(array('entityHandles' => $debtorHandles))-> Debtor_GetDataArrayResult->DebtorData;
 
But When i Use This, I only get the number:
 
$debtor_name =  'Schmidt & Co.';     //mysql_real_escape_string($_POST['firma_quick']);
$debtorHandle = $client->Debtor_FindByName(array('name' => $debtor_name))->Debtor_FindByNameResult;
$debtorDataObjects = $client->Debtor_GetDataArray(array('entityHandles' => $debtorHandle))-> Debtor_GetDataArrayResult->DebtorData;
 
<?php   foreach ($debtorDataObjects as $i => $debtorData) {   ?>
 
<tr>
 
<form action="order.php?firma_id=<?php echo $debtorData->Number  ;?>" method="post">
 
<td><?php print $debtorData->Number ?>&nbsp;</td>
 
<td><?php print $debtorData->Name ?>&nbsp;</td>
 
<td><?php print $debtorData->Address ?>&nbsp;</td>
 
<td><?php print $debtorData->PostalCode ?>&nbsp;</td>
 
<td><?php print $debtorData->City ?>&nbsp;</td>
 
<td><?php print $debtorData->Country ?>&nbsp;</td>
 
<td class="white_field">
 
<input type="hidden" name="action" value="show_orders">
 
<input type="hidden" name="debtor_number" value="<?php print $debtorData->Number ?>">
 
<input type="submit" value="Opret ordre">
 
</td></form></tr>

 

created Aug 15, 2015 by suulut
50% Accept Rate
Q 8 A 5 C 2

2 Answers

0
 
Best answer
Debtor_FindByName: the result is one debtor, therefore $debtorDataObjects should be:
$debtorDataObjects = $client->Debtor_GetData(array('entityHandle' => $debtorHandles))->Debtor_GetDataResult;
Debtor_GetData: Handles only data from one debtor
Debtor_GetDataArray: Handles data from two or more debtors.
ALSO the foreach line needs to be changed to: $debtor = $debtorDataObjects;
instead of: <?php   foreach ($debtorDataObjects as $i => $debtorData) {   ?>
the right print is:
<?php   $debtor = $debtorDataObjects;  ?>
 
<tr>
 
<form action="order.php?firma_id=<?php echo $debtorData->Number  ;?>" method="post">
 
<td><?php print $debtorData->Number ?>&nbsp;</td>
 
<td><?php print $debtorData->Name ?>&nbsp;</td>
 
<td><?php print $debtorData->Address ?>&nbsp;</td>
 
 

 

answered Oct 5, 2015 by suulut
0
Hi suulut

Debtor_FindByName takes a string and not an object.
answered Sep 8, 2015 by olej

Network

Find all the documentation and resources you need to build great apps.
Go to Developer site

Newsletter

Get the latest news and important info from the e-conomic developer world.
Sign up now

Visma e-conomic A/S
...