3 * Test Generated example of using activity getfields API
6 function activity_getfields_example(){
12 $result = civicrm_api3('activity', 'getfields', $params);
14 catch (CiviCRM_API3_Exception
$e) {
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
26 * Function returns array of result expected from previous function
28 function activity_getfields_expectedresult(){
30 $expectedResult = array(
35 'source_record_id' => array(
36 'name' => 'source_record_id',
38 'title' => 'Source Record',
40 'activity_type_id' => array(
41 'name' => 'activity_type_id',
43 'title' => 'Activity Type',
46 'where' => 'civicrm_activity.activity_type_id',
47 'headerPattern' => '/(activity.)?type(.id$)/i',
52 'pseudoconstant' => array(
53 'optionGroupName' => 'activity_type',
56 'activity_date_time' => array(
57 'name' => 'activity_date_time',
59 'title' => 'Activity Date',
61 'where' => 'civicrm_activity.activity_date_time',
62 'headerPattern' => '/(activity.)?date(.time$)?/i',
65 'type' => 'Select Date',
71 'title' => 'Phone (called) ID',
72 'FKClassName' => 'CRM_Core_DAO_Phone',
74 'type' => 'Autocomplete-Select',
77 'phone_number' => array(
78 'name' => 'phone_number',
80 'title' => 'Phone (called) Number',
87 'priority_id' => array(
88 'name' => 'priority_id',
90 'title' => 'Priority',
94 'pseudoconstant' => array(
95 'optionGroupName' => 'priority',
99 'name' => 'parent_id',
101 'title' => 'Parent Activity Id',
102 'FKClassName' => 'CRM_Activity_DAO_Activity',
109 'relationship_id' => array(
110 'name' => 'relationship_id',
112 'title' => 'Relationship Id',
114 'FKClassName' => 'CRM_Contact_DAO_Relationship',
116 'is_current_revision' => array(
117 'name' => 'is_current_revision',
119 'title' => 'Is this activity a current revision in versioning chain?',
121 'where' => 'civicrm_activity.is_current_revision',
122 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
126 'type' => 'CheckBox',
129 'original_id' => array(
130 'name' => 'original_id',
132 'title' => 'Original Activity ID ',
133 'FKClassName' => 'CRM_Activity_DAO_Activity',
146 'title' => 'Activity ID',
149 'where' => 'civicrm_activity.id',
151 'uniqueName' => 'activity_id',
152 'api.aliases' => array(
153 '0' => 'activity_id',
159 'title' => 'Subject',
163 'where' => 'civicrm_activity.subject',
164 'headerPattern' => '/(activity.)?subject/i',
169 'uniqueName' => 'activity_subject',
172 'name' => 'duration',
174 'title' => 'Duration',
176 'where' => 'civicrm_activity.duration',
177 'headerPattern' => '/(activity.)?duration(s)?$/i',
182 'uniqueName' => 'activity_duration',
185 'name' => 'location',
187 'title' => 'Location',
191 'where' => 'civicrm_activity.location',
192 'headerPattern' => '/(activity.)?location$/i',
197 'uniqueName' => 'activity_location',
202 'title' => 'Details',
206 'where' => 'civicrm_activity.details',
207 'headerPattern' => '/(activity.)?detail(s)?$/i',
210 'type' => 'RichTextEditor',
212 'uniqueName' => 'activity_details',
214 'status_id' => array(
215 'name' => 'status_id',
217 'title' => 'Activity Status',
219 'where' => 'civicrm_activity.status_id',
220 'headerPattern' => '/(activity.)?status(.label$)?/i',
224 'pseudoconstant' => array(
225 'optionGroupName' => 'activity_status',
227 'uniqueName' => 'activity_status_id',
228 'api.aliases' => array(
229 '0' => 'activity_status',
237 'where' => 'civicrm_activity.is_test',
238 'headerPattern' => '/(is.)?test(.activity)?/i',
243 'uniqueName' => 'activity_is_test',
245 'medium_id' => array(
246 'name' => 'medium_id',
248 'title' => 'Activity Medium',
253 'pseudoconstant' => array(
254 'optionGroupName' => 'encounter_medium',
256 'uniqueName' => 'activity_medium_id',
267 'uniqueName' => 'activity_result',
269 'is_deleted' => array(
270 'name' => 'is_deleted',
272 'title' => 'Activity is in the Trash',
274 'where' => 'civicrm_activity.is_deleted',
275 'headerPattern' => '/(activity.)?(trash|deleted)/i',
280 'uniqueName' => 'activity_is_deleted',
282 'campaign_id' => array(
283 'name' => 'campaign_id',
285 'title' => 'Campaign',
287 'where' => 'civicrm_activity.campaign_id',
289 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
291 'type' => 'CheckBox',
293 'pseudoconstant' => array(
294 'table' => 'civicrm_campaign',
296 'labelColumn' => 'title',
298 'uniqueName' => 'activity_campaign_id',
300 'engagement_level' => array(
301 'name' => 'engagement_level',
303 'title' => 'Engagement Index',
305 'where' => 'civicrm_activity.engagement_level',
310 'pseudoconstant' => array(
311 'optionGroupName' => 'engagement_index',
313 'uniqueName' => 'activity_engagement_level',
315 'source_contact_id' => array(
316 'name' => 'source_contact_id',
317 'title' => 'Activity Source Contact',
319 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
320 'api.default' => 'user_contact_id',
322 'assignee_contact_id' => array(
323 'name' => 'assignee_id',
324 'title' => 'assigned to',
326 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
328 'target_contact_id' => array(
329 'name' => 'target_id',
330 'title' => 'Activity Target',
332 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
337 return $expectedResult;
342 * This example has been generated from the API test suite. The test that created it is called
344 * testGetFields and can be found in
345 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
347 * You can see the outcome of the API tests at
348 * https://test.civicrm.org/job/CiviCRM-master-git/
350 * To Learn about the API read
351 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
353 * Browse the api on your own site with the api explorer
354 * http://MYSITE.ORG/path/to/civicrm/api/explorer
356 * Read more about testing here
357 * http://wiki.civicrm.org/confluence/display/CRM/Testing
359 * API Standards documentation:
360 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards