I had an error in my Order/Opportunity field map which prevented creation of the Opportunity record in Salesforce. However, the error was not correctly reported due to the code problem below:

File: uc_sf_order/uc_sf_order.module
Starting line: 757

    if (!$response->success) {
      drupal_set_message(t('Error exporting order to Salesforce.'), 'error');
      sf_dpm($response->errors->message, 'Ubercart order error');
      return FALSE;
    }

When I dumped the actual $response object, it was contained:

(Array, 1 element)
	0 (Object) stdClass
		errors (Array, 1 element)
			0 (Object) stdClass
				fields (Array, 1 element)
				message (String, 65 characters ) Donation Record Type: id value of incorrect typ...
					Donation Record Type: id value of incorrect type: Single Donation
				statusCode (String, 12 characters ) MALFORMED_ID
		id (NULL)
		success (Boolean) FALSE

So it appears the correct code should be:

    if (!$response->success) {
      drupal_set_message(t('Error exporting order to Salesforce.'), 'error');
      $error_msgs = array();
      foreach($response->errors as $i => $error) {
        $error_msgs[] = $error->message;
      }
      sf_dpm(implode('; ', $error_msgs), 'Ubercart order error');
      return FALSE;
    }

These changes are reflected in the attached patch.txt

Comments

benjaminbradley’s picture

same problem around line 903 (after adding the code above):

        foreach ($ocr_responses as $ocr_response) {
          if (!$ocr_response->success) {
            watchdog('uc_sf_order', 'Failed to export Opportunity Contact Role to Salesforce. <pre>' . print_r($ocr_response, 1) . '</pre><pre>' . print_r($ocr_node, 1) . '</pre><
            sf_dpm($ocr_response->errors->message, 'OpportunityContactRole error');
          }
        }

should be:

          if (!$ocr_response->success) {
            watchdog('uc_sf_order', 'Failed to export Opportunity Contact Role to Salesforce. <pre>' . print_r($ocr_response, 1) . '</pre><pre>' . print_r($ocr_node, 1) . '</pre><
            $error_msgs = array();
            foreach($ocr_response->errors as $i => $error) {
              $error_msgs[] = $error->message;
            }
            sf_dpm(implode('; ', $error_msgs), 'OpportunityContactRole error');
          }
EvanDonovan’s picture

Yes, this makes sense to me. The underlying issue here is that PHP toolkit changed how error reporting works.

I'll try to commit this in the next week or so.

EvanDonovan’s picture

Thanks, I have a work-in-progress branch to fix this in all the places it occurs. Hopefully I'll have sorted out the issues shortly.

kenorb’s picture

StatusFileSize
new6.86 KB
kenorb’s picture

Priority: Normal » Minor
Issue summary: View changes