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

will not create Debtors

0
Hello
Is not there some who might try to help me to explain whether there are errors in my code and why it will not create a Debtors it comes up with this error

--------------------------[ code ]-----------------------------------------

    function economic_connect($url, $agreement, $user, $pass) {
       $client = new SoapClient($url, array(trace = 1, exceptions = 1));          
       $client-Connect(array('agreementNumber' = $agreement,'userName' = $user, 'password' = $pass));
        return $client;
    }

    $api_url = 'https://www.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL';
    $agreement_number = '**Protected**';
    $username = '**Protected**';
    $password = '**Protected**';
    $client = economic_connect($api_url, $agreement_number, $username, $password);
   
    $params = array(
        'debitor_number' = '10016',
        'debitor_name' = 'Bo testsen',
        'debitor_email' = 'test@test.dk',
        'debitor_phone_and_fax' = '80808080',
        'debitor_website' = 'http://www.testtest.dk',
        'debitor_address' = 'et eller andet sted',
        'debitor_postalcode' = '1100',
        'debitor_city' = 'en eller anden gade',
        'debitor_country' = 'Danmark',
        'debitor_cvr' = '123456789',
        'currency' = 'DKK',
        'debitor_attention' = 'Homer Simpson');

        $debtor = $client-Debtor_FindByName(array('name' = $params['debitor_name']))-Debtor_FindByNameResult-DebtorHandle;
        $term_of_payment_name = konto 8 dage;
        $term_of_Collection_name = DK. std. m. girokort 1.4;
        $TermOfPaymentHandles = $client-TermOfPayment_FindByName(array('name' = $term_of_payment_name))-TermOfPayment_FindByNameResult-TermOfPaymentHandle;
        $TemplateCollectionHandle = $client-TemplateCollection_FindByName(array('name' = $term_of_Collection_name))-TemplateCollection_FindByNameResult-TemplateCollectionHandle;
        $DebtorGroupHandles = $client-debtorGroup_GetAll()-DebtorGroup_GetAllResult-DebtorGroupHandle;
        $currencys = $client-Currency_FindByCode(array('code' = $params['currency']))-Currency_FindByCodeResult;
        $EmployeeHandles = $client-Employee_FindByName(array('name' = 'YOYO'))-Employee_FindByNameResult-EmployeeHandle;

        
    if (!$debtor) {

    $debtor_data = array(
      'IsAccessible' = true,
          'VatZone' = 'HomeCountry',
      'number' = $params['debitor_number'],
          'Name' = $params['debitor_name'],
          'Email' = $params['debitor_email'],
          'TelephoneAndFaxNumber' = $params['debitor_phone_and_fax'],
          'Website' = $params['debitor_website'],
          'Address' = $params['debitor_address'],
          'PostalCode' = $params['debitor_postalcode'],
          'City' = $params['debitor_city'],
          'Country' = $params['debitor_country'],
          'DebtorGroupHandle' = $DebtorGroupHandles
          'CurrencyHandle' = $currencys,
          'TermOfPaymentHandle' = $TermOfPaymentHandles,
          'LayoutHandle' = $TemplateCollectionHandle,
          'OurReferenceHandle' = $EmployeeHandles);        

    $client-Debtor_CreateFromData(array('data' = $debtor_data));
    }
created Nov 8, 2010 by expnet
0% Accept Rate
Q 1 A 0 C 0

2 Answers

0
I don't see the error message you say you get.
Post the error messages please.
While looking quickly thru your code i noticed
'number' = $params['debitor_number'],
I have 'Number' in my array, that could be the problem.
Hard to tell without any error message.
answered Nov 10, 2010 by Madman
0
Hello there.

when i in create a debtor i do it this way

        $newDebtorHandle = $this-soap_client-Debtor_Create( array(
            'number'            = $this-debtor_number,
            'debtorGroupHandle' = array(
                'Number' = $this-debtor_group_handle
            ),
            'name'              = $this-debtor_name,
            'vatZone'           = 'EU'))-Debtor_CreateResult;

        $this-soap_client-Debtor_SetAddress( array(
            'debtorHandle' = $newDebtorHandle,
            'value'        = $this-debtor_street
            )
        );

        $this-soap_client-Debtor_SetCity( array(
            'debtorHandle' = $newDebtorHandle,
            'value'        = $this-debtor_city
            )
        );

        $this-soap_client-Debtor_SetEmail( array(
            'debtorHandle' = $newDebtorHandle,
            'value'        = $this-debtor_email
            )
        );

        $this-soap_client-Debtor_SetPostalCode( array(
            'debtorHandle' = $newDebtorHandle,
            'value'        = $this-debtor_zipcode
            )
        );

        $this-soap_client-Debtor_SetTelephoneAndFaxNumber( array(
            'debtorHandle' = $newDebtorHandle,
            'value'        = $this-debtor_phonenumber
            )
        );

        $this-soap_client-Debtor_SetIsAccessible( array(
            'debtorHandle' = $newDebtorHandle,
            'value'        = true
            )
        );

first create a debtor basic and after that, set all data for this detor, its fastere, i try your way first but its get trobbels, i use this way now.

hobe its use full.
answered Nov 17, 2010 by ParisNakitaKejser
Visma e-conomic A/S
...