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

Bug report: DepartmentFindByName doesn't return a valid Handle

0
Hey all,

Have been trying out the deparment/dimension module and accessing it via the API and the results/response is not valid.

Searching by a valid name (double checked) results in an empty handle. See below.

        try {
            $department_finder = new \Economic\Department_FindByName();
            $department_finder->number = $data->DepartmentName;
            $department_result = $ws->Department_FindByName($department_finder);
            var_dump($department_result);
            $cb_data->DepartmentHandle = $department_result->Department_FindByNameResult;

        } catch (Exception $e) {
            throw new Exception("No department found. (" . $cb_data->DepartmentName .")\n"
                . $e->getMessage());
        }

       object(Economic\Department_FindByNameResponse)#7 (1) {
         ["Department_FindByNameResult"]=>
         object(stdClass)#10 (0) {
         }
       }

 

Trying the same with Department find by number

        try {
            $department_finder = new \Economic\Department_FindByNumber();
            $department_finder->number = $data->DepartmentNumber;
            $department_result = $ws->Department_FindByNumber($department_finder);
            $cb_data->DepartmentHandle = $department_result->Department_FindByNumberResult;

        } catch (Exception $e) {
            throw new Exception("No department found. (" . $cb_data->DepartmentNumber .")\n"
                . $e->getMessage());
        }

       object(Economic\Department_FindByNumberResponse)#7 (1) {
         ["Department_FindByNumberResult"]=>
         object(Economic\DepartmentHandle)#10 (1) {
           ["Number"]=>
           int(5)
         }
       }

So it looks like it's not being set when fetching the Department by name. Any way this can be fixed? Or if it is in fact not a bug that someone can tell me what I'm doing wrong.
created Jun 17, 2013 by tg24
100% Accept Rate
Q 6 A 3 C 5

1 Answer

0
 
Best answer
Hi tg24.

I can confirm that "Department_FindByName" is working fine.

If you don't get any result, it must be because you are sending a non-existing name.
answered Jun 18, 2013 by Jostein
selected Jun 18, 2013 by tg24
That's weird since I copy pasted the value of the Department from the e-conomic interface into my code.

Shouldn't you respond with something else than a Result though ? I think I remember getting NULL back instead of a Result object when something was not found. Or maybe call it something else than a Department_FindByNameResult, like EmptyResult or NotFoundResult ?
It's working for me now so that's good.

I still think my comments above are valid.
Glad to hear that it works for you now.
The Response is as designed, and works like this for all commands. If you find any commands that you think differs please do not hesitate in contacting us again.
Visma e-conomic A/S
...