Salesforce - update / delete custom object

UPDATE: it works as expected, just need to pass the correct identifier, DUH! ~

I have a custom object in salesforce, sort of like a comment section for an example. When you add a new comment, it has a date / time stamp for this entry, I would like to update the previous comment date / time phrase of the comment when a new comment for the case is created.

I wanted to do UPDATE as follows:

$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";
        $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 also tried UPSERT but I get the error:

Missing argument 2 for SforcePartnerClient::upsert()

Any help would be great

+3
source share
1 answer

Spirit, I realized, missed the wrong Id. need to pass a comment but passed recordId

+1
source

Source: https://habr.com/ru/post/1736338/


All Articles