I was wondering how is it possible to limit the visibility of the enumeration values in an enumeration E according to one condition specified in an input form (for example current operator group, or one named right the operator owns)
ENUM E: A,B,C,D
OPERATOR GROUP "OpA" --> Field myValue using ENUM E : dropdown list will show values A,B,C
OPERATOR GROUP "OpB" --> Field myValue using ENUM E : dropdown list will show values B,D
Could you tell me how is it possible to do that inside an input form ?
Thanks in advance,
It's possible to do that with this steps:
- Creation of a relation table between the Operators and the Enumeration Values tables (N-N), this table will contains the operatorId and the enumValueId (same principle than between the recipients and the recipients lists).
- Linking the Operators and the Enumeration Values tables with the new relation table.
- Adding a "sysFilter" in the input defined in the input form:
<condition expr="[enumValueOperatorRel/@operator-id] = $(@operator-id)"/>
I found a way to filtering very easily the values of an enumeration coming from a schema. In fact, you have just to add a "enabledIf" attribute with a "HasNamedRight('myRightName')":
<enumeration basetype="string" default="A" name="example">
<value enabledIf="HasNamedRight('OpA')" label="A" name="A" value="A"/>
<value enabledIf="HasNamedRight('OpA') or HasNamedRight('OpB')" label="B" name="B" value="B"/>
<value enabledIf="HasNamedRight('OpA')" label="C" name="C" value="C"/>
<value enabledIf="HasNamedRight('OpB')" label="D" name="D" value="D"/>
The named right can be applied on an operator or a group.
Please note that an administrator can see all the values even if he haven't the good right.
Sorry i didnt get it
can someone explain this solution in more details
You can do this with schema sysfilters and joins. Sysfilter you're conditionally appending predicates to the where clause, usually current operator has a right or is admin. I'm not sure how dbEnums behave with schema sysfilters tacked on (to xtk:enum), but sounds like something that should work.
The principle works with the enumeration values but I unfortunately did not found a way to apply this to the enumerations from schemas.
It is possible to create two enumerations in the schema and call the good one in the form depending on the operator but this solution means that we have two different fields in the database and I think it's not really clean.
It's more complicated to do that with the groups.
Indeed, an operator can be linked to many groups so it's difficult to set the "sysFilter" tag.
If it's possible, I don't know how. Sorry to can't help more.
Can this be done on an operator group level? the goal here not to update the relationship table every time a new operator/user is being created/added to the system.