Last active
August 29, 2015 13:57
-
-
Save dbarbar/9399443 to your computer and use it in GitHub Desktop.
sf.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$batch = array( | |
'sobjects' => array( | |
'aobject 0', | |
'sobject 1', | |
'sobject 2', | |
'sobject 3', | |
'sobject 4', | |
'sobject 5', | |
), | |
'items' => array( | |
'item 0', | |
'item 1', | |
'item 2', | |
'item 3', | |
'item 4', | |
'item 5', | |
), | |
); | |
var_export($batch); | |
print PHP_EOL . PHP_EOL; | |
foreach ($batch['sobjects'] as $index => $sobject) { | |
if ($sobject == 'sobject 2' || $sobject == 'sobject 4') { | |
// Fail the item. | |
print "failed item " . $batch['items'][$index] . PHP_EOL; | |
// Unset the object, and the item. | |
unset($batch['sobjects'][$index]); | |
unset($batch['items'][$index]); | |
} | |
} | |
// Reset array indicies in each array to prevent Salesforce from throwing SOAP error. | |
$batch['sobjects'] = array_values($batch['sobjects']); | |
$batch['items'] = array_values($batch['items']); | |
var_export($batch); | |
print PHP_EOL . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment