4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using activity getfields API.
15 function activity_getfields_example() {
21 $result = civicrm_api3('activity', 'getfields', $params);
23 catch (CiviCRM_API3_Exception
$e) {
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
29 'error' => $errorMessage,
30 'error_code' => $errorCode,
31 'error_data' => $errorData,
39 * Function returns array of result expected from previous function.
44 function activity_getfields_expectedresult() {
46 $expectedResult = array(
51 'source_record_id' => array(
52 'name' => 'source_record_id',
54 'title' => 'Source Record',
56 'activity_type_id' => array(
57 'name' => 'activity_type_id',
59 'title' => 'Activity Type',
62 'where' => 'civicrm_activity.activity_type_id',
63 'headerPattern' => '/(activity.)?type(.id$)/i',
68 'pseudoconstant' => array(
69 'optionGroupName' => 'activity_type',
72 'activity_date_time' => array(
73 'name' => 'activity_date_time',
75 'title' => 'Activity Date',
77 'where' => 'civicrm_activity.activity_date_time',
78 'headerPattern' => '/(activity.)?date(.time$)?/i',
81 'type' => 'Select Date',
87 'title' => 'Phone (called) ID',
88 'FKClassName' => 'CRM_Core_DAO_Phone',
90 'type' => 'Autocomplete-Select',
92 'FKApiName' => 'Phone',
94 'phone_number' => array(
95 'name' => 'phone_number',
97 'title' => 'Phone (called) Number',
104 'priority_id' => array(
105 'name' => 'priority_id',
107 'title' => 'Priority',
111 'pseudoconstant' => array(
112 'optionGroupName' => 'priority',
115 'parent_id' => array(
116 'name' => 'parent_id',
118 'title' => 'Parent Activity Id',
119 'FKClassName' => 'CRM_Activity_DAO_Activity',
120 'FKApiName' => 'Activity',
127 'relationship_id' => array(
128 'name' => 'relationship_id',
130 'title' => 'Relationship Id',
132 'FKClassName' => 'CRM_Contact_DAO_Relationship',
133 'FKApiName' => 'Relationship',
135 'is_current_revision' => array(
136 'name' => 'is_current_revision',
138 'title' => 'Is this activity a current revision in versioning chain?',
140 'where' => 'civicrm_activity.is_current_revision',
141 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
145 'type' => 'CheckBox',
148 'original_id' => array(
149 'name' => 'original_id',
151 'title' => 'Original Activity ID ',
152 'FKClassName' => 'CRM_Activity_DAO_Activity',
153 'FKApiName' => 'Activity',
166 'title' => 'Activity ID',
169 'where' => 'civicrm_activity.id',
171 'uniqueName' => 'activity_id',
172 'api.aliases' => array(
173 '0' => 'activity_id',
179 'title' => 'Subject',
183 'where' => 'civicrm_activity.subject',
184 'headerPattern' => '/(activity.)?subject/i',
189 'uniqueName' => 'activity_subject',
192 'name' => 'duration',
194 'title' => 'Duration',
196 'where' => 'civicrm_activity.duration',
197 'headerPattern' => '/(activity.)?duration(s)?$/i',
202 'uniqueName' => 'activity_duration',
205 'name' => 'location',
207 'title' => 'Location',
211 'where' => 'civicrm_activity.location',
212 'headerPattern' => '/(activity.)?location$/i',
217 'uniqueName' => 'activity_location',
222 'title' => 'Details',
226 'where' => 'civicrm_activity.details',
227 'headerPattern' => '/(activity.)?detail(s)?$/i',
230 'type' => 'RichTextEditor',
232 'uniqueName' => 'activity_details',
234 'status_id' => array(
235 'name' => 'status_id',
237 'title' => 'Activity Status',
239 'where' => 'civicrm_activity.status_id',
240 'headerPattern' => '/(activity.)?status(.label$)?/i',
244 'pseudoconstant' => array(
245 'optionGroupName' => 'activity_status',
247 'uniqueName' => 'activity_status_id',
248 'api.aliases' => array(
249 '0' => 'activity_status',
257 'where' => 'civicrm_activity.is_test',
258 'headerPattern' => '/(is.)?test(.activity)?/i',
263 'uniqueName' => 'activity_is_test',
265 'medium_id' => array(
266 'name' => 'medium_id',
268 'title' => 'Activity Medium',
273 'pseudoconstant' => array(
274 'optionGroupName' => 'encounter_medium',
276 'uniqueName' => 'activity_medium_id',
287 'uniqueName' => 'activity_result',
289 'is_deleted' => array(
290 'name' => 'is_deleted',
292 'title' => 'Activity is in the Trash',
294 'where' => 'civicrm_activity.is_deleted',
295 'headerPattern' => '/(activity.)?(trash|deleted)/i',
300 'uniqueName' => 'activity_is_deleted',
302 'campaign_id' => array(
303 'name' => 'campaign_id',
305 'title' => 'Campaign',
307 'where' => 'civicrm_activity.campaign_id',
309 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
311 'type' => 'CheckBox',
313 'pseudoconstant' => array(
314 'table' => 'civicrm_campaign',
316 'labelColumn' => 'title',
318 'uniqueName' => 'activity_campaign_id',
319 'FKApiName' => 'Campaign',
321 'engagement_level' => array(
322 'name' => 'engagement_level',
324 'title' => 'Engagement Index',
326 'where' => 'civicrm_activity.engagement_level',
331 'pseudoconstant' => array(
332 'optionGroupName' => 'engagement_index',
334 'uniqueName' => 'activity_engagement_level',
336 'source_contact_id' => array(
337 'name' => 'source_contact_id',
338 'title' => 'Activity Source Contact',
340 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
341 'api.default' => 'user_contact_id',
343 'assignee_contact_id' => array(
344 'name' => 'assignee_id',
345 'title' => 'assigned to',
347 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
349 'target_contact_id' => array(
350 'name' => 'target_id',
351 'title' => 'Activity Target',
353 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
358 return $expectedResult;
362 * This example has been generated from the API test suite.
363 * The test that created it is called
365 * and can be found in
366 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
368 * You can see the outcome of the API tests at
369 * https://test.civicrm.org/job/CiviCRM-master-git/
371 * To Learn about the API read
372 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
374 * Browse the api on your own site with the api explorer
375 * http://MYSITE.ORG/path/to/civicrm/api/explorer
377 * Read more about testing here
378 * http://wiki.civicrm.org/confluence/display/CRM/Testing
380 * API Standards documentation:
381 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards