quaho - 2012-11-09

Hello,

I am still working on the 1.2 version of itop since i have very little time and the 2.0 is only in its beta version (i am also testing it though).
I am trying to add something similar to skill management on a contact by adding a skill attribute to an Application to see if this application requires or not some particular expertise and then to be able on a Person's details to select the applications he has the expertise in on an "application skill" tab.

In order to do that, I added  the skill attribute in the class Application :

MetaModel::Init_AddAttribute(new AttributeEnum("skill", array("allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"skill", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));

And created a lnkApplicationToContact class :

class lnkApplicationToContact extends cmdbAbstractObject
{

public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable,structure",
"key_type" => "autoincrement",
"name_attcode" => "application_id",
"state_attcode" => "",
"reconc_keys" => array("application_id","contact_id"),
"db_table" => "lnkapplicationtocontact",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();

MetaModel::Init_AddAttribute(new AttributeExternalKey("application_id", array("targetclass"=>"Application", "jointype"=>null, "allowed_values"=>new ValueSetObjects("SELECT Application FROM Application WHERE skill = 'yes'"), "sql"=>"application_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("application_name", array("allowed_values"=>null, "extkey_attcode"=>"application_id", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"Contact", "jointype"=>null, "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("allowed_values"=>null, "extkey_attcode"=>"contact_id", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));

MetaModel::Init_SetZListItems('details', array('application_id', 'contact_id'));
MetaModel::Init_SetZListItems('advanced_search', array('application_id', 'contact_id'));
MetaModel::Init_SetZListItems('standard_search', array('application_id', 'contact_id'));
MetaModel::Init_SetZListItems('list', array('application_id', 'contact_id'));
}
}

Finally I added the skill tab on the Contact class :

MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("skill_list", array("linked_class"=>"lnkApplicationToContact", "ext_key_to_me"=>"contact_id", "ext_key_to_remote"=>"application_id", "allowed_values"=>new ValueSetObjects('SELECT Application FROM Application WHERE skill = "yes"'), "count_min"=>0, "count_max"=>0, "depends_on"=>array())));

The goal is that when adding an application in the application skill tab, he is only able to choose between the applications where the skill attribute is set to yes, so I put an OQL Request on the allowed values of the "skill_list" and in the lnkApplicationToContact class but it doesn't work and I can choose any application, whether the skill attribute is set to yes or no.

I have run out of ideas on how to make this filter work, can someone help me with this issue?

Thanks,
Quaho