0
votes

I make a demo script to create a new Sales Order by PHP. Here is my code:

$acumatica = new AcumaticaGate($this->acuAccName,$this->acuAccPass,$this->acuServiceUrl);

        $SO301000GetSchema = $acumatica->client->SO301000GetSchema(new ObjectDocument\GetSchema());
        $SO301000GetSchema = $SO301000GetSchema->GetSchemaResult;
        $acumatica->client->SO301000Clear(new ObjectDocument\Clear());

        $SO301000Submit = new ObjectDocument\Submit();

        $SO301000Submit->commands = array
        (
            $acumatica->prepareValue("SO", $SO301000GetSchema->OrderSummary->OrderType),
            $acumatica->prepareValue("<NEW>", $SO301000GetSchema->OrderSummary->OrderNbr),
            $acumatica->prepareValue("ACTIVESTAF", $SO301000GetSchema->OrderSummary->Customer),

            $SO301000GetSchema->DocumentDetails->ServiceCommands->NewRow,
            $acumatica->prepareValue("AALEGO500", $SO301000GetSchema->DocumentDetails->InventoryID, true),
            $acumatica->prepareValue("HQ", $SO301000GetSchema->DocumentDetails->Branch),

            $SO301000GetSchema->Actions->Save
        );
        $result = $acumatica->client->SO301000Submit($SO301000Submit);
        print_r($result);

Everything is ok, It insert a new Sales Order in Acumatica site. But the result that I print doesn't have the content. Here is ther result of statement print_r($result)

stdClass Object
(
    [SubmitResult] => stdClass Object
        (
        )
)
1
Submit returns a multi-dimensional array. Are you sure that print_r in PHP can properly output it? Can you try using var_dump instead? - Gabriel
I have the answer for this question: Add the field that we want to return after the command $SO301000GetSchema->Actions->Save, Ex: $SO301000GetSchema->Actions->Save, $SO301000GetSchema->OrderSummary->OrderNbr Beside that, I dont know what about C#, but in PHP, I must to replace the command: $acumatica->prepareValue("<NEW>", $SO301000GetSchema->OrderSummary->OrderNbr), By the command: $SO301000GetSchema->Actions->Insert, - Thuy Tran

1 Answers

0
votes

You don't receive any field back because you didn't specify the field names after invoking the Save action. If you add the fields to the commands array, they will be returned in the result, for example

    $SO301000Submit->commands = array
    (
        $acumatica->prepareValue("SO", $SO301000GetSchema->OrderSummary->OrderType),
        $acumatica->prepareValue("<NEW>", $SO301000GetSchema->OrderSummary->OrderNbr),
        $acumatica->prepareValue("ACTIVESTAF", $SO301000GetSchema->OrderSummary->Customer),

        $SO301000GetSchema->DocumentDetails->ServiceCommands->NewRow,
        $acumatica->prepareValue("AALEGO500", $SO301000GetSchema->DocumentDetails->InventoryID, true),
        $acumatica->prepareValue("HQ", $SO301000GetSchema->DocumentDetails->Branch),

        $SO301000GetSchema->Actions->Save

        // Fields to be returned added here
        $SO301000GetSchema->OrderSummary->OrderNbr
        $SO301000GetSchema->OrderSummary->CuryOrderTotal
    );