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

Order Entry Transaction Functions do not return results #198

Open
ryanflores-bayalarm opened this issue Jul 29, 2024 · 1 comment
Open

Comments

@ryanflores-bayalarm
Copy link

When creating, updating, and deleting results using the following classes, the Result object within the OnlineResponse object returns an empty array:

  • /src/Intacct/Functions/OrderEntry/OrderEntryTransactionCreate
  • /src/Intacct/Functions/OrderEntry/OrderEntryTransactionUpdate
  • /src/Intacct/Functions/OrderEntry/OrderEntryTransactionDelete

More specifically, OnlineResponse::$results[0]->data is empty when in fact something should be returned. This is important because it would help to receive the value of DOCID so that follow-up requests could be made. This is especially important for OrderEntryTransactionCreate to return the value so that follow-up requests could be made using either OrderEntryTransactionUpdate or OrderEntryTransactionDelete when needed.

As an interim solution, users would have to make a wasteful Query, searching for the SODOCUMENT object that was just created in order to get the value DOCID.

I did some research into why an empty array was being returned, and it's because the <key> isn't wrapped in a <data> element and/or <SODOCUMENT> element, which I believe the SDK (or response handler) is expecting with the response that's returned. Here's a sample of what the <result> element looks like as returned by OrderEntryTransactionCreate:

        <result>
            <status>success</status>
            <function>create_sotransaction</function>
            <controlid>[REDACTED]</controlid>
            <key>Sales Order-[REDACTED]</key>
        </result>

Here's a sample of what gets returned by other requests when Result::$data is NOT empty:

        <result>
            <status>success</status>
            <function>query</function>
            <controlid>[REDACTRED]</controlid>
            <data listtype="SODOCUMENT" totalcount="1" offset="0" count="1" numremaining="0">
                <SODOCUMENT>
                    <RECORDNO>[REDACTRED]</RECORDNO>
                    <DOCNO>[REDACTRED]</DOCNO>
                    <DOCID>Sales Order-[REDACTRED]</DOCID>
                    <DOCPARID>Sales Order</DOCPARID>
                </SODOCUMENT>
            </data>
        </result>

It would also be nice if RECORDNO were returned when creating a sales order in addition to DOCID in case it might be needed for something.

@ryanflores-bayalarm
Copy link
Author

Here's a sample of what we have to do just to get the value of DOCID after creating a new sales order, which is a wasteful API request since the data has already been confirmed as being returned by the create request:

try {
    $fields = [new Field('DOCID')];

    $filter = new Filter('DOCNO');
    $filter->equalTo('[REDACTED]');

    $query = new Query();
    $query->setFrom('SODOCUMENT');
    $query->setSelect($fields);
    $query->setFilter($filter);

    $response = $client->execute($query);
    $result = $response->getResult();
}
catch (ResponseException $e) {
    echo 'Failed! ' . $e->getMessage();
}

return json_decode(json_encode($result->getData()))[0]->DOCID ?? null;

I also noticed (or couldn't find a way) to set the returnFormat to json. It looks like xml is hard-coded and hence why we have to use both json_encode() and json_decode() to easily parse the return data.

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

1 participant