Hi there,
I have resolved many issues with the upsert. I do have a question. I'm uploading another file over two the same account object, however, I seem to be having an issue with parent field. I put Parent:field_name and of course that didn't work.
Any ideas in how to upsert with parent field??
Thanks!
Kevin,
I am sorry I just do not get what you are asking.
Can you show me some code or try and explain it a little more
Hi there,
Sorry for the delay.. Here is some source code to help you.
$all_fields = array();
$i = 0;
while ($rec_1 = mysql_fetch_assoc($rec))
{
$all_fields[$i]['main_id'] = htmlspecialchars($acct_1['id']);
$all_fields[$i]['Name'] = htmlspecialchars($acct_1['account_name']);
$all_fields[$i]['Phone'] = htmlspecialchars($acct_1['phone']);
$all_fields[$i]['BillingStreet'] = htmlspecialchars($acct_1['premise_address_1']);
$all_fields[$i]['BillingCity'] = htmlspecialchars($acct_1['premise_city']);
$all_fields[$i]['Parent:main_id'] = htmlspecialchars($acct_1['parent_account']);
}
foreach ($all_fields as $fieldset)
{
$sObject = new sObject();
$sObject->type = 'Account'; // Salesforce Table or object that you will perform the upsert on
$sObject->fields = $fieldset;
array_push($sObjects, $sObject);
}
$success = upsert_accounts($client, $sObjects, $file_updated, $file_created, $file_failed);
if (is_array($success))
{
$accounts_created = $accounts_created + $success[0];
$accounts_updated = $accounts_updated + $success[1];
$accounts_failed = $accounts_failed + $success[2];
}
$starting_record = $starting_record + $number_records;
ob_start();
$total_record_count = $total_record_count + $record_count;
echo $total_record_count." records processed.<br />";
ob_end_flush();
I don't know if you need any more. But the main problem is that I can't seem to bound the parent field with the record field.
Let me know if you need any more code.
Hi Kevin,
It looks like you have your own functions in there so it will be hard to tell exactly what is going on.
From a first glance i can see that you have wrong field names on your left hand side.
Let me try and give you an example with correct fields names:
As I do not have a copy of your function,PHP Code:## ONLY USE WHEN UPSERTING ##
$all_fields[$i]['Id'] = htmlspecialchars($acct_1['id']);
## BE CAREFUL - IF YOUR SALESFORCE ORG IS CONFIGURED FOR PERSON ACCOUNTS
## THEN THIS FIELD SHOULD NOT BE WRITTEN TO
$all_fields[$i]['Name'] = htmlspecialchars($acct_1['account_name']);
## THESE FIELDS LOOK OK ##
$all_fields[$i]['Phone'] = htmlspecialchars($acct_1['phone']);
$all_fields[$i]['BillingStreet'] = htmlspecialchars($acct_1['premise_address_1']);
$all_fields[$i]['BillingCity'] = htmlspecialchars($acct_1['premise_city']);
## THIS IS THE PARENT ACCOUNT FIELD NAME
## PLEASE NOTE THAT YOU NEED TO INSERT A PROPER 18
## CHARACTER VALID ACCOUNT ID FOR THIS TO BE SUCCESSFUL
$all_fields[$i]['ParentId'] = htmlspecialchars("00190000001xH0FAAU");
I'm not able to verify if there are more issues that lie in there. I am assuming by your $client in that function you are declaring your Id field when upserting?PHP Code:$success = upsert_accounts($client, $sObjects, $file_updated, $file_created, $file_failed);
Here is the developerforce.com page for Upsert if you haven't come across it yet.PHP Code:$upsertResponse = $mySforceConnection->upsert("Id", array ($sObject));
PHP Toolkit 13.0 Upsert Sample (Partner) - developer.force.com
Thank you Adam..
Bookmarks