Answers.Body: <p>This may be a permissions issue, depending on who is the logged-in user when your code runs and whether they have permission to create cases. If you want your code to run anyway regardless of who is logged-in, you could add <code>'check_permissions' =&gt; FALSE</code> to your api $params.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-28T20:53:53.653Z
Answers.LastActivityDate: 2015-05-28T20:53:53.653Z
Answers.UserDisplayName: Coleman
Body: <p>In my drupal custom module I am creating a case object via</p>
  
  <p>$result = civicrm_api3('case', 'create', $params); </p>
  
  <p>This function on debugging api.php file is returning the case id but in my module it is returning the null value </p>
  
  <p>I want it to return the case id. How would i do so?
  Here code Snippet</p>
  
  <pre>     
  function form_test_form_submit($form, &$form_state)
  $params = array( 
      'subject' => 'Test case',
      'contact_id' => 64771, 
      'case_type' => 'test', 
  );
  
  $case = testcase_create($params);
  
  function testcase_create($params){
      civicrm_initialize(); 
      require_once 'api/api.php';
  
      try{ 
          $result = civicrm_api3('case', 'create', $params); 
      }
      catch (CiviCRM_API3_Exception $e) { 
          $errorMessage = $e->getMessage();
          $errorCode = $e->getErrorCode();
          $errorData = $e->getExtraParams();
          return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
      } 
      return $result; // the value of $result is NULL, where as in api.php it was not NULL as seen in debugging
   }
  </pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-27T07:56:43.770Z
Comments.Text: I can able to create case in drupal custom module in earlier civicrm was upgraded that is xml problem.
Comments.UserDisplayName: M Sivani
Tags: <drupal>
Title: Drupal custom module civicase is creating but it is returning null value?
ThreadText: # Drupal custom module civicase is creating but it is returning null value?
  
  (Asked by: username_0 on 2015-05-20)
  
  In my drupal custom module I am creating a case object via
  $result = civicrm_api3('case', 'create', $params); 
  This function on debugging api.php file is returning the case id but in my module it is returning the null value 
  I want it to return the case id. How would i do so?
  Here code Snippet
       
  function form_test_form_submit($form, &$form_state)
  $params = array( 
      'subject' => 'Test case',
      'contact_id' => 64771, 
      'case_type' => 'test', 
  );
  
  $case = testcase_create($params);
  
  function testcase_create($params){
      civicrm_initialize(); 
      require_once 'api/api.php';
  
      try{ 
          $result = civicrm_api3('case', 'create', $params); 
      }
      catch (CiviCRM_API3_Exception $e) { 
          $errorMessage = $e->getMessage();
          $errorCode = $e->getErrorCode();
          $errorData = $e->getExtraParams();
          return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
      } 
      return $result; // the value of $result is NULL, where as in api.php it was not NULL as seen in debugging
   }
  
  **Tags:** drupal
  
  > **Comments:**
  > **username_0**: I can able to create case in drupal custom module in earlier civicrm was upgraded that is xml problem.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-05-28. Score: 1
  
  This may be a permissions issue, depending on who is the logged-in user when your code runs and whether they have permission to create cases. If you want your code to run anyway regardless of who is logged-in, you could add `'check_permissions' => FALSE` to your api $params.
  
  
  ---
  
  