Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find() needs a select variable? #34

Closed
voicecode-bv opened this issue Dec 26, 2015 · 3 comments
Closed

find() needs a select variable? #34

voicecode-bv opened this issue Dec 26, 2015 · 3 comments

Comments

@voicecode-bv
Copy link

When I want to update a purchaseEntry with a newly uploaded document, I get this following error:

Error 400: Please add a $select or a $top=1 statement to the query string.

I'm using this lines to fetch the right purchaseEntry.

$purchaseInvoice    = new \Picqer\Financials\Exact\PurchaseEntry($connection);
$purchaseInvoice    = $purchaseInvoice->find($purchaseInvoiceID);
$purchaseInvoice->Document = $documentID;
$purchaseInvoice->update();

When I change the find() function in Findable.php like this:

public function find($id, $select = '')
    {

        $result = $this->connection()->get($this->url, [
            '$filter' => $this->primaryKey . " eq guid'$id'",
            '$select' => $select
        ]);

        return new self($this->connection(), $result);
    }

Using this, it seems to work.

$purchaseInvoice    = new \Picqer\Financials\Exact\PurchaseEntry($connection);
$purchaseInvoice    = $purchaseInvoice->find($purchaseInvoiceID, 'EntryID, Document');
$purchaseInvoice->Document = $documentID;
$purchaseInvoice->update();
@stephangroen
Copy link
Member

Strange, according to the docs just using an EntryID should work. I don't have any experience with PurchaseEntries myself.

You could use the filter method though, instead of an altered find() :

$purchaseInvoice->filter("EntryID eq '$purchaseInvoiceID'", '', 'EntryID, Document');

@voicecode-bv
Copy link
Author

Hmm strange, when I use the filter method, I get an 400 error:
Error 400: Operator 'eq' incompatible with operand types 'System.Guid' and 'System.String' at position 8.

When I do:
$purchaseInvoice->filter($purchaseInvoiceID, '', 'EntryID, Document');

This error comes up:
Error 400: No property 'c319fc7b' exists in type 'Exact.Web.Api.Models.PurchaseEntry' at position 0.
Don't know where c319fc7b comes from and it changes every request.

@stephangroen
Copy link
Member

Fixed in #36 and v2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants