update agent custom fields

This commit is contained in:
marcos 2021-09-28 09:31:06 +02:00
parent a7e97f0493
commit a8a5289652
2 changed files with 13 additions and 1 deletions

View File

@ -242,6 +242,7 @@ our @EXPORT = qw(
pandora_update_agent_module_count
pandora_update_config_token
pandora_update_agent_custom_field
pandora_select_id_custom_field
pandora_update_gis_data
pandora_update_module_on_error
pandora_update_module_from_hash
@ -3407,6 +3408,17 @@ sub pandora_update_config_token ($$$) {
return $result;
}
##########################################################################
## Select custom field id by name tagent_custom_field
##########################################################################
sub pandora_select_id_custom_field ($$) {
my ($dbh, $field) = @_;
my $result = undef;
$result = get_db_single_row ($dbh, 'SELECT id_field FROM tagent_custom_fields WHERE name = ? ', safe_input($field));
return $result;
}
##########################################################################
## Update a custom field from agent of tagent_custom_data

View File

@ -3063,7 +3063,7 @@ sub cli_agent_update_custom_fields() {
}
# Department, Serial number ...
my $custom_field = get_db_single_row ($dbh, 'SELECT id_field FROM tagent_custom_fields WHERE name = ? ', safe_input($field));
my $custom_field = pandora_select_id_custom_field ($dbh, $field);
if($custom_field eq '') {
print_log "[ERROR] Field '$field' doesnt exist\n\n";