3 * Test Generated example demonstrating the Activity.getfields API.
8 function activity_getfields_example() {
14 $result = civicrm_api3('Activity', 'getfields', $params);
16 catch (CiviCRM_API3_Exception
$e) {
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
23 'error_message' => $errorMessage,
24 'error_code' => $errorCode,
25 'error_data' => $errorData,
33 * Function returns array of result expected from previous function.
38 function activity_getfields_expectedresult() {
45 'source_record_id' => [
46 'name' => 'source_record_id',
48 'title' => 'Source Record',
49 'description' => 'Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.',
50 'table_name' => 'civicrm_activity',
51 'entity' => 'Activity',
52 'bao' => 'CRM_Activity_BAO_Activity',
54 'activity_type_id' => [
55 'name' => 'activity_type_id',
57 'title' => 'Activity Type ID',
58 'description' => 'FK to civicrm_option_value.id, that has to be valid, registered activity type.',
61 'where' => 'civicrm_activity.activity_type_id',
62 'headerPattern' => '/(activity.)?type(.id$)/i',
65 'table_name' => 'civicrm_activity',
66 'entity' => 'Activity',
67 'bao' => 'CRM_Activity_BAO_Activity',
74 'optionGroupName' => 'activity_type',
75 'optionEditPath' => 'civicrm/admin/options/activity_type',
78 'activity_date_time' => [
79 'name' => 'activity_date_time',
81 'title' => 'Activity Date',
82 'description' => 'Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.',
84 'where' => 'civicrm_activity.activity_date_time',
85 'headerPattern' => '/(activity.)?date(.time$)?/i',
87 'table_name' => 'civicrm_activity',
88 'entity' => 'Activity',
89 'bao' => 'CRM_Activity_BAO_Activity',
91 'type' => 'Select Date',
92 'format' => 'activityDateTime',
98 'title' => 'Phone (called) ID',
99 'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
100 'table_name' => 'civicrm_activity',
101 'entity' => 'Activity',
102 'bao' => 'CRM_Activity_BAO_Activity',
103 'FKClassName' => 'CRM_Core_DAO_Phone',
105 'type' => 'EntityRef',
109 'FKApiName' => 'Phone',
112 'name' => 'phone_number',
114 'title' => 'Phone (called) Number',
115 'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
118 'table_name' => 'civicrm_activity',
119 'entity' => 'Activity',
120 'bao' => 'CRM_Activity_BAO_Activity',
128 'name' => 'priority_id',
130 'title' => 'Priority',
131 'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
132 'table_name' => 'civicrm_activity',
133 'entity' => 'Activity',
134 'bao' => 'CRM_Activity_BAO_Activity',
140 'pseudoconstant' => [
141 'optionGroupName' => 'priority',
142 'optionEditPath' => 'civicrm/admin/options/priority',
146 'name' => 'parent_id',
148 'title' => 'Parent Activity Id',
149 'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
150 'table_name' => 'civicrm_activity',
151 'entity' => 'Activity',
152 'bao' => 'CRM_Activity_BAO_Activity',
153 'FKClassName' => 'CRM_Activity_DAO_Activity',
154 'FKApiName' => 'Activity',
160 'table_name' => 'civicrm_activity',
161 'entity' => 'Activity',
162 'bao' => 'CRM_Activity_BAO_Activity',
164 'relationship_id' => [
165 'name' => 'relationship_id',
167 'title' => 'Relationship Id',
168 'description' => 'FK to Relationship ID',
170 'table_name' => 'civicrm_activity',
171 'entity' => 'Activity',
172 'bao' => 'CRM_Activity_BAO_Activity',
173 'FKClassName' => 'CRM_Contact_DAO_Relationship',
174 'FKApiName' => 'Relationship',
176 'is_current_revision' => [
177 'name' => 'is_current_revision',
179 'title' => 'Is this activity a current revision in versioning chain?',
181 'where' => 'civicrm_activity.is_current_revision',
182 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
185 'table_name' => 'civicrm_activity',
186 'entity' => 'Activity',
187 'bao' => 'CRM_Activity_BAO_Activity',
189 'type' => 'CheckBox',
193 'name' => 'original_id',
195 'title' => 'Original Activity ID ',
196 'description' => 'Activity ID of the first activity record in versioning chain.',
197 'table_name' => 'civicrm_activity',
198 'entity' => 'Activity',
199 'bao' => 'CRM_Activity_BAO_Activity',
200 'FKClassName' => 'CRM_Activity_DAO_Activity',
201 'FKApiName' => 'Activity',
207 'table_name' => 'civicrm_activity',
208 'entity' => 'Activity',
209 'bao' => 'CRM_Activity_BAO_Activity',
219 'title' => 'Is Starred',
220 'description' => 'Activity marked as favorite.',
222 'where' => 'civicrm_activity.is_star',
223 'headerPattern' => '/(activity.)?(star|favorite)/i',
225 'table_name' => 'civicrm_activity',
226 'entity' => 'Activity',
227 'bao' => 'CRM_Activity_BAO_Activity',
232 'title' => 'Activity ID',
233 'description' => 'Unique Other Activity ID',
236 'where' => 'civicrm_activity.id',
238 'table_name' => 'civicrm_activity',
239 'entity' => 'Activity',
240 'bao' => 'CRM_Activity_BAO_Activity',
241 'uniqueName' => 'activity_id',
243 '0' => 'activity_id',
249 'title' => 'Subject',
250 'description' => 'The subject/purpose/short description of the activity.',
254 'where' => 'civicrm_activity.subject',
255 'headerPattern' => '/(activity.)?subject/i',
257 'table_name' => 'civicrm_activity',
258 'entity' => 'Activity',
259 'bao' => 'CRM_Activity_BAO_Activity',
265 'uniqueName' => 'activity_subject',
268 'name' => 'duration',
270 'title' => 'Duration',
271 'description' => 'Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.',
273 'where' => 'civicrm_activity.duration',
274 'headerPattern' => '/(activity.)?duration(s)?$/i',
276 'table_name' => 'civicrm_activity',
277 'entity' => 'Activity',
278 'bao' => 'CRM_Activity_BAO_Activity',
284 'uniqueName' => 'activity_duration',
287 'name' => 'location',
289 'title' => 'Location',
290 'description' => 'Location of the activity (optional, open text).',
294 'where' => 'civicrm_activity.location',
295 'headerPattern' => '/(activity.)?location$/i',
297 'table_name' => 'civicrm_activity',
298 'entity' => 'Activity',
299 'bao' => 'CRM_Activity_BAO_Activity',
305 'uniqueName' => 'activity_location',
310 'title' => 'Details',
311 'description' => 'Details about the activity (agenda, notes, etc).',
313 'where' => 'civicrm_activity.details',
314 'headerPattern' => '/(activity.)?detail(s)?$/i',
316 'table_name' => 'civicrm_activity',
317 'entity' => 'Activity',
318 'bao' => 'CRM_Activity_BAO_Activity',
320 'type' => 'RichTextEditor',
324 'uniqueName' => 'activity_details',
327 'name' => 'status_id',
329 'title' => 'Activity Status',
330 'description' => 'ID of the status this activity is currently in. Foreign key to civicrm_option_value.',
332 'where' => 'civicrm_activity.status_id',
333 'headerPattern' => '/(activity.)?status(.label$)?/i',
334 'table_name' => 'civicrm_activity',
335 'entity' => 'Activity',
336 'bao' => 'CRM_Activity_BAO_Activity',
342 'pseudoconstant' => [
343 'optionGroupName' => 'activity_status',
344 'optionEditPath' => 'civicrm/admin/options/activity_status',
346 'uniqueName' => 'activity_status_id',
348 '0' => 'activity_status',
356 'where' => 'civicrm_activity.is_test',
357 'headerPattern' => '/(is.)?test(.activity)?/i',
359 'table_name' => 'civicrm_activity',
360 'entity' => 'Activity',
361 'bao' => 'CRM_Activity_BAO_Activity',
365 'uniqueName' => 'activity_is_test',
368 'name' => 'medium_id',
370 'title' => 'Activity Medium',
371 'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
373 'table_name' => 'civicrm_activity',
374 'entity' => 'Activity',
375 'bao' => 'CRM_Activity_BAO_Activity',
381 'pseudoconstant' => [
382 'optionGroupName' => 'encounter_medium',
383 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
385 'uniqueName' => 'activity_medium_id',
391 'description' => 'Currently being used to store result id for survey activity, FK to option value.',
394 'table_name' => 'civicrm_activity',
395 'entity' => 'Activity',
396 'bao' => 'CRM_Activity_BAO_Activity',
402 'uniqueName' => 'activity_result',
405 'name' => 'is_deleted',
407 'title' => 'Activity is in the Trash',
409 'where' => 'civicrm_activity.is_deleted',
410 'headerPattern' => '/(activity.)?(trash|deleted)/i',
412 'table_name' => 'civicrm_activity',
413 'entity' => 'Activity',
414 'bao' => 'CRM_Activity_BAO_Activity',
418 'uniqueName' => 'activity_is_deleted',
421 'name' => 'campaign_id',
423 'title' => 'Campaign',
424 'description' => 'The campaign for which this activity has been triggered.',
426 'where' => 'civicrm_activity.campaign_id',
428 'table_name' => 'civicrm_activity',
429 'entity' => 'Activity',
430 'bao' => 'CRM_Activity_BAO_Activity',
431 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
433 'type' => 'CheckBox',
437 'pseudoconstant' => [
438 'table' => 'civicrm_campaign',
440 'labelColumn' => 'title',
442 'uniqueName' => 'activity_campaign_id',
443 'FKApiName' => 'Campaign',
445 'engagement_level' => [
446 'name' => 'engagement_level',
448 'title' => 'Engagement Index',
449 'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
451 'where' => 'civicrm_activity.engagement_level',
453 'table_name' => 'civicrm_activity',
454 'entity' => 'Activity',
455 'bao' => 'CRM_Activity_BAO_Activity',
461 'pseudoconstant' => [
462 'optionGroupName' => 'engagement_index',
463 'optionEditPath' => 'civicrm/admin/options/engagement_index',
465 'uniqueName' => 'activity_engagement_level',
467 'source_contact_id' => [
468 'name' => 'source_contact_id',
469 'title' => 'Activity Source Contact',
470 'description' => 'Person who created this activity. Defaults to current user.',
472 'FKClassName' => 'CRM_Contact_DAO_Contact',
473 'api.default' => 'user_contact_id',
474 'FKApiName' => 'Contact',
476 'assignee_contact_id' => [
477 'name' => 'assignee_id',
478 'title' => 'Activity Assignee',
479 'description' => 'Contact(s) assigned to this activity.',
481 'FKClassName' => 'CRM_Contact_DAO_Contact',
482 'FKApiName' => 'Contact',
484 'target_contact_id' => [
485 'name' => 'target_id',
486 'title' => 'Activity Target',
487 'description' => 'Contact(s) participating in this activity.',
489 'FKClassName' => 'CRM_Contact_DAO_Contact',
490 'FKApiName' => 'Contact',
494 'title' => 'Case ID',
495 'description' => 'For creating an activity as part of a case.',
497 'FKClassName' => 'CRM_Case_DAO_Case',
498 'FKApiName' => 'Case',
503 return $expectedResult;
507 * This example has been generated from the API test suite.
508 * The test that created it is called "testGetFields"
509 * and can be found at:
510 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
512 * You can see the outcome of the API tests at
513 * https://test.civicrm.org/job/CiviCRM-master-git/
515 * To Learn about the API read
516 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
518 * Browse the api on your own site with the api explorer
519 * http://MYSITE.ORG/path/to/civicrm/api
521 * Read more about testing here
522 * http://wiki.civicrm.org/confluence/display/CRM/Testing
524 * API Standards documentation:
525 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards