I have a problem when creating a link table:
I have a key (site_id) that must be the same in both classes in the link table: I.e. I only want to see hostObjects with the same site as the hostGroup to be choosable in the list:
I have tried various approaches, this for example (with hardcoded site_id as 1):
class lnkHostobjectToHostgroup extends cmdbAbstractObject
{
}
}
But I still can choose between all host_object belonging to all site:
Is there a way to filter the lnik-list before showing them to the user?
I have also tried to move the allowed_values command to the HostGroup class, without success:
Shall a more complicate approach be used, using the DisplayBareRelations command?
All suggestions are welcome, as this is stopping my implementation.
BR
Anders
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the same problem and i've been searching for a solution for a while now but couldn't find any.
Have you managed to solve your issue or can anybody help with this issue?
Thanks,
Quaho
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a problem when creating a link table:
I have a key (site_id) that must be the same in both classes in the link table: I.e. I only want to see hostObjects with the same site as the hostGroup to be choosable in the list:
I have tried various approaches, this for example (with hardcoded site_id as 1):
class lnkHostobjectToHostgroup extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable,structure",
"key_type" => "autoincrement",
"name_attcode" => "hostgroup_id",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "lnkHostobjectToHostgroup",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("hostgroup_id", array("targetclass"=>"HostGroup", "jointype"=>null, "allowed_values"=>null, "sql"=>"hostgroup_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("hostobject_id", array("targetclass"=>"HostObject", "jointype"=>null, "allowed_values"=>new ValueSetObjects("SELECT HostObject WHERE site_id = 1"), "sql"=>"hostobject_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL,"depends_on"=>array("hostgroup_id"))));
MetaModel::Init_SetZListItems('details', array('hostobject_id'));
MetaModel::Init_SetZListItems('advanced_search', array('hostobject_id'));
MetaModel::Init_SetZListItems('standard_search', array('hostobject_id'));
}
}
But I still can choose between all host_object belonging to all site:
Is there a way to filter the lnik-list before showing them to the user?
I have also tried to move the allowed_values command to the HostGroup class, without success:
Shall a more complicate approach be used, using the DisplayBareRelations command?
All suggestions are welcome, as this is stopping my implementation.
BR
Anders
Hi,
I have the same problem and i've been searching for a solution for a while now but couldn't find any.
Have you managed to solve your issue or can anybody help with this issue?
Thanks,
Quaho
I had a similair problem, with query on a external key field. Added a new field as attr.string. And did the WHERE clause on this field. Worked!