开发者

Salesforce - Update/Upsert custom object entry

开发者 https://www.devze.com 2022-12-23 00:03 出处:网络
UPDATE: It\'s working as expected just needed to pass the correct Id, DUH!~ I have a custom object in salesforce, kind of like the comments section on a case for example. When you add a new comment i

UPDATE: It's working as expected just needed to pass the correct Id, DUH!~

I have a custom object in salesforce, kind of like the comments section on a case for example. When you add a new comment it has a date/time stamp for that entry, I wanted to update the previous case comment date/time stamp when a new case comment is created.

I wanted to do an UPDATE like this:

$updateFields = array(
                'Id'=>$comment_id, // This is the Id for each comment
                'End_Date__c'=>$record_last_modified_date
            );

function sfUpdateLastCommentDate($sfConnection, $updateFields) {
    try {        
        $sObjectCustom = new SObject();
        $sObjectCustom->type = 'Case_Custom__c';

        $sObjectCustom->fields = $updateFields;
        $createResponse = $sfConnection->update(array($sObjectCustom));              
    } catch(Exception $e) {
        $error_msg  = SALESFORCE_ERROR." \n";
     开发者_StackOverflow社区   $error_msg .= $e->faultstring;
        $error_msg .= $sfConnection->getLastRequest();
        $error_msg .= SALESFORCE_MESSAGE_BUFFER_NEWLINE;

        // Send error message
        mail(ERROR_TO_EMAIL, ERROR_EMAIL_SUBJECT, $error_msg, ERROR_EMAIL_HEADER_WITH_CC);
        exit;
    }
}

I've also tried the UPSERT but I get the error:

Missing argument 2 for SforcePartnerClient::upsert()

Any help would be great


Duh, I figured it out, was passing the wrong Id. needed to pass the commentId but was passing the recordId

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号