I am creating new extension.
I am adding a new custom field into Activity tab but it's not working
//Creating a custom group for survey
function custom_group_create_survey(){
$survey_custom_group = array(
"id" => "10",
"name" => "API_survey",
"title" => "API survey",
"extends" => "Activity",
"extends_entity_column_value" => [
"1"
],
"style" => "Inline",
"collapse_display" => "1",
"weight" => " 3",
"is_active" => "1",
"table_name" => "civicrm_value_API_sur__5",
"is_multiple" => "0",
"collapse_adv_display" => "0",
"created_id" => "2",
"created_date" => "",
"is_reserved" => "0",
"is_public" => "1"
);
try{
$result = civicrm_api3('CustomGroup', 'create', $survey_custom_group);
}
catch (CiviCRM_API3_Exception $e) {
// Handle error here.
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
return array(
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
);
}
return $result;
}
function custom_field_create_survey() {
$params = array(
'custom_group_id' => 10,
'name' => 'test_textfield2',
'label' => 'Name1',
'html_type' => 'Text',
'data_type' => 'String',
'default_value' => 'abc',
'weight' => 4,
'is_required' => 1,
'is_searchable' => 0,
'is_active' => 1,
);
try{
$result = civicrm_api3('CustomField', 'create', $params);
}
catch (CiviCRM_API3_Exception $e) {
// Handle error here.
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
return array(
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
);
}
return $result;
} ##
I am calling these functions into following hook
function surveytab_civicrm_install() {
custom_group_create_survey();
custom_field_create_survey();
_surveytab_civix_civicrm_install(); } ##