I'm trying to ensure that a specific field in the Organization class does not appear for users that have the "Portal User" profile. The issue is that I do not believe GetAttributeFlags nor GetInitialStateAttributeFlags is invoking properly. I've tried it for both the customer portal and the backoffice. Itop version is 3.1.0. I'm looking to hide or remove the field.
Would anyone have an idea about this?
<?xml version="1.0" encoding="UTF-8"?><itop_designxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"version="1.6"><constants></constants><classes><classid="Organization"_delta="must_exist"><fields><fieldid="organization_customerclass"xsi:type="AttributeString"_delta="define"><sql>organization_customerclass</sql><default_value/><is_null_allowed>true</is_null_allowed><on_target_delete>DEL_AUTO</on_target_delete></field></fields><presentation><details><items><itemid="tab:Info"_delta="define"><rank>32</rank><items><itemid="fieldset:Info"><rank>10</rank><items><itemid="organization_customerclass"><rank>10</rank></item></items></item></items></item></items></details></presentation><methods><methodid="GetAttributeFlags"_delta="define"><static>false</static><access>public</access><code><![CDATA[ public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '') { IssueLog::Info("GetAttributeFlags called for $sAttCode"); if (($sAttCode == 'organization_customerclass') && (UserRights::HasProfile('Portal User'))) { return(OPT_ATT_READONLY | OPT_ATT_HIDDEN | parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState)); } return parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState); } ]]></code></method><methodid="GetInitialStateAttributeFlags"_delta="define"><static>false</static><access>public</access><code><![CDATA[ public function GetInitialStateAttributeFlags($sAttCode, &$aReasons = array()) { IssueLog::Info("GetInitialStateAttributeFlags called for $sAttCode"); if (($sAttCode == 'organization_customerclass') && (UserRights::HasProfile('Portal User'))) { return(OPT_ATT_READONLY | OPT_ATT_HIDDEN | parent::GetInitialStateAttributeFlags($sAttCode, $aReasons)); } return parent::GetInitialStateAttributeFlags($sAttCode, $aReasons); } ]]></code></method></methods></class></classes><menus></menus><user_rights><groups></groups><profiles></profiles></user_rights></itop_design>
Last edit: Cyro 2025-06-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using GetAttributeFlags to hide a field of a class to a Portal User, is not the easiest solution.
When you are a Portal User, you only have access on itop-portal, adding a specific form, for the class Organization on the Portal, without that particular field, does the job...
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Heya,
I'm trying to ensure that a specific field in the Organization class does not appear for users that have the "Portal User" profile. The issue is that I do not believe GetAttributeFlags nor GetInitialStateAttributeFlags is invoking properly. I've tried it for both the customer portal and the backoffice. Itop version is 3.1.0. I'm looking to hide or remove the field.
Would anyone have an idea about this?
Last edit: Cyro 2025-06-26
Heya,
Looks like the issue was that UserRights::HasProfile('Portal User') should be lowercase: UserRights::HasProfile('Portal user')
Using GetAttributeFlags to hide a field of a class to a Portal User, is not the easiest solution.
When you are a Portal User, you only have access on itop-portal, adding a specific form, for the class Organization on the Portal, without that particular field, does the job...