Commit 31f9ba4f authored by FoucherAurelie's avatar FoucherAurelie
Browse files

api3 for create

parent 15b2eaf9
Pipeline #30380 passed with stages
in 16 seconds
Showing with 9 additions and 9 deletions
+9 -9
......@@ -221,7 +221,7 @@ function civicrm_api3_education_nationale_populate($params) {
}
}
$item = ['values' => [
$item = [
'contact_type' => "Organization",
'contact_sub_type' => "EducationalInstitution",
'contact_source' => 'API Education Nationale',
......@@ -230,7 +230,7 @@ function civicrm_api3_education_nationale_populate($params) {
'is_primary' => 1,
],
'checkPermissions' => FALSE,
]];
];
foreach ($dataset['datasrc'] as $local_field => $attribute) {
if(isset($custom_fields[$local_field])){
$local_field = $custom_fields[$local_field];
......@@ -238,26 +238,26 @@ function civicrm_api3_education_nationale_populate($params) {
$item[$local_field] = $record->fields->$attribute;
}
foreach ($dataset['addressdatasrc'] as $local_field => $attribute) {
$item['values']['api.Address.create'][$local_field] = isset($record->fields->$attribute) ? $record->fields->$attribute : '';
$item['api.Address.create'][$local_field] = isset($record->fields->$attribute) ? $record->fields->$attribute : '';
}
if (isset($record->fields->coordonnees) && ! empty($record->fields->coordonnees)) {
$lattitude = $record->fields->coordonnees[0];
$longitude = $record->fields->coordonnees[1];
$item['values']['api.Address.create']['geo_code_1'] = $lattitude;
$item['values']['api.Address.create']['geo_code_2'] = $longitude;
$item['api.Address.create']['geo_code_1'] = $lattitude;
$item['api.Address.create']['geo_code_2'] = $longitude;
}
// Post cleanup
if(strlen($item['organization_name']) > 128){
$item['values']['organization_name'] = substr($item['values']['organization_name'], 0, 127).'…';
$item['organization_name'] = substr($item['organization_name'], 0, 127).'…';
}
if($item['values']['organization_name'] == ''){
$item['values']['organization_name'] = sprintf(E::ts('Empty name: %s'), $contact['external_identifier']);
if($item['organization_name'] == ''){
$item['organization_name'] = sprintf(E::ts('Empty name: %s'), $contact['external_identifier']);
}
try{
$imported = civicrm_api4('Contact', 'create', $item);
$imported = civicrm_api3('Contact', 'create', $item);
}
catch(CiviCRM_API3_Exception $e){
$EducationalInstitutions[] = [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment