<?php
-
-/*
- Demonstrate retrieving metadata with custom field options
+/**
+ * Test Generated example of using contact GetFields API
+ * Demonstrate retrieving metadata with custom field options *
*/
function contact_getfields_example(){
$params = array(
'options' => array(
'get_options' => 'custom_1',
),
- 'version' => 3,
'action' => 'create',
);
- $result = civicrm_api( 'contact','GetFields',$params );
+try{
+ $result = civicrm_api3('contact', 'GetFields', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+ // handle error here
+ $errorMessage = $e->getMessage();
+ $errorCode = $e->getErrorCode();
+ $errorData = $e->getExtraParams();
+ return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
- return $result;
+return $result;
}
-/*
+/**
* Function returns array of result expected from previous function
*/
function contact_getfields_expectedresult(){
'extends_entity_column_id' => '',
'is_view' => 0,
'is_multiple' => 0,
- 'option_group_id' => '97',
+ 'option_group_id' => '99',
'date_format' => '',
'time_format' => '',
'name' => 'custom_1',
),
);
- return $expectedResult ;
+ return $expectedResult;
}