Skip to content

BULK/Batch Create Records, The quickest way to create multiple new records in Dynamics CRM. #79

Open
@smartinsight-at

Description

@smartinsight-at

What is the best way to approach creating multiple new records in a batch on a a Dynamics CRM. I am successfully creating individual records but this seems a slow process.

I have to create 300,000 records a day in the CRM as a log of all emails sent out by the client. The table has been created and I can do it one record at a time, each post takes about 3-4 seconds. As the time seems to be in the call and response, can I bulk upload e.g 100 records+ at a time and get back an array of Records Id's created in the same way as I get the record Id when I create a single item.

If possible an Example would be appreciated.

Our current method that works for single records is as follows.

    require_once '../vendor/autoload.php';

    $settings = new \AlexaCRM\WebAPI\OData\OnlineSettings();
    $settings->instanceURI = 'https://xxxxxxxxxx.dynamics.com';
    $settings->applicationID = 'xxxxxxx-xxxxxx-xxxx-xxxxx-exxxxxxxxx';
    $settings->applicationSecret = 'Btl8QXXXXXXXXXXXXXXXXXXX';
    $settings->apiVersion = '9.2';

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

$record = new \AlexaCRM\Xrm\Entity('xpg_trackedactivity'); // this is to create new existing

$record['xpg_source'] = 930590000;
$record['xpg_description'] = $row['description'];
$record['xpg_campaignname'] = $row['campaignname'];

try {
// run your code here
$externalresult=$client->Create( $record );
$status="Sent";
}
catch (exception $e) {
$status="Error";
//code to handle the exception
echo "error Trapped: ".$e;
}

Many Thanks
Adam Taylor

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions