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

When updating a record using an id that does not exist, it creates an unwanted blank record #94

Open
smartinsight-at opened this issue Sep 18, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@smartinsight-at
Copy link

When I update specific fields for a record in Dynamics, if the record has since been removed (Deleted) from Dynamics, it creates blank record in its place rather than just failing as the id was not found.

What I want is a safe method of updating that will not create lots of new records when the client removes them from the CRM.

I am sure I am doing something wrong in my code, but I do not know what.

$middleware = new \AlexaCRM\WebAPI\OData\OnlineAuthMiddleware( $settings );
$odataClient = new \AlexaCRM\WebAPI\OData\Client( $settings, $middleware );
$client = new \AlexaCRM\WebAPI\Client( $odataClient );

      $recordeng  = new \AlexaCRM\Xrm\Entity( 'contact', $row['externalid'] );
      $recordeng['engagementscore']  = $row['score'];

        try {
            // run your code here
            $externalresulteng=$client->update( $recordeng );
       
        }
        catch (exception $e) {
       echo "<br>error Trapped: ".$e."<br>";    
       }

This seems to relate to me pushing the id for a record that has now been removed, hence it creates the record.

@georged georged added the enhancement New feature or request label Oct 3, 2023
@georged
Copy link
Contributor

georged commented Oct 3, 2023

@smartinsight-at we need to implement Limit upsert operations. I'm thinking of this (preudo) syntax:

$client->update( $recordeng, LimitUpsert: NONE (default) | LimitUpsert: NOCREATE | LimitUpsert: NOUPDATE );

@smartinsight-at
Copy link
Author

smartinsight-at commented Oct 3, 2023 via email

@georged
Copy link
Contributor

georged commented Oct 3, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants