Menu

Typology linked to org_id

6 days ago
2 days ago
  • Guillaume Vaillant

    Hello,

    I have a "Ticket" class with an "AttributeExternalKey" field that points to a typology class.

    This typology class has an org_id field to select the associated organization.

    On my "Ticket," if my user has access to all organizations, they will see all the entries in my typology class (which is normal). However, if they select an organization in the sidebar, they still see all the entries in that field, regardless of the organization (which shouldn't be the case since I've selected one organization).

    A user who doesn't have access to all organizations will only see the entries for their own organization.

    Do you know how I can solve this problem?

    Thank you

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 6 days ago

    Have you considered simply renaming "org_id" to a different name?
    "org_id" is kind of a special field in iTop, which can restrict visibility.

     
  • Guillaume Vaillant

    Hello,
    This is what i want, when i select the org on the sidebar i want to only see the Typology from the selected org.

     
  • Vincent @ Combodo

    Hi Guillaume,
    We have not implemented that the organization selector restrict the external Key selection when editing an object. In your mind, it make sense to restrict the typology value based on the selected organization, but if we were applying this rule, then you could no more select a Service which would not be delivered by the customer organization, while creating a User Request in console which the Customer Selected, you could not select an agent or a team,... clearly, there are very good reason not to do it.
    And for your particular need:
    You can ask the agents to use the magnifier and filter the typology based on a particular organization.
    Or if there is a rule defining when the typology values must be restricted and when its free, maybe you can code it with the typology external key OQL filter...

     
  • Guillaume Vaillant

    Hi Vincent,

    thank you for your answer.

    I think i'll put a filter on the field where i need to get specific Typology linked to org.

     
  • Guillaume Vaillant

    @cisou
    Could you help me with the request, because the problem is that the selected org is not the same as the typo org. The org inside my class is a child or of the main org, where my typo are linked.

    ORG_parent (all my typo are linked here
    Child_org (my "Ticket are linked to this)

    So i think it will be hard with the filter : <filter><![CDATA[SELECT Type WHERE org_id = $this->org_id]]></filter>

    in the filter we cannot have php code ?

    Maybe with a method PrefillCreationForm ?

     
  • Vincent @ Combodo

    Express your need more clearly?
    Do you want to restrict the proposed typology, based on
    1. a User Profile
    2. Particular Customers
    3. Particular Service or Service-subcategories
    4. The requestor organization and its parent(s)

    If you have no clear rule to decide when to limit the proposed typology to those of the customer, versus all the typology, then the only possible filter I can think of, is to always propose the ticket requestor organization owned Types and all the generic Types defined on the Parent organization(s) - (option 4)

    SELECT Type AS t
    JOIN Organization AS root ON t.org_id=root.id
    JOIN Organization AS child ON child.parent_id BELOW root.id
    WHERE child.id = $this->org_id
    

    This filter n°4 has the advantage not to propose any specific Types which would apply only to a different sub-organization than the one of the requestor.

     
  • Guillaume Vaillant

    So.

    Org :
    A (parent)
    - B (child)
    C (other parent)

    Type :
    - TOTO (linked to A org)
    - TITI (linked to A org)
    - TATA (linked to C org)
    - TUTU (linked to C org)

    The user connected (can see every org) can create a "Ticket" (custom class) On the creation form, we select the org of the ticket, we select B.
    With the org B selected i would like to see only the Type linked to A

    And if we create a "Ticket" linked to org C i would like to see only the Type linked to C

    Is it better ? :)

     
  • Vincent @ Combodo

    The option 4 should do the work.

     
  • Guillaume Vaillant

    Thank you, i've try,

    It's working in the run query menu and when i edit an already existing "Ticket".
    But when i try to create a new one, nothing is shown in the field select Type :/

     
  • Vincent @ Combodo

    Have you selected a Customer, before opening the drop-down field Type ?

     
  • Guillaume Vaillant

    yes,
    This is how i define the org on the Ticket :
    <field id="user-content-org_id" xsi:type="AttributeExternalKey">
    <filter><![CDATA[SELECT Organization AS org
    JOIN Location AS loc ON loc.org_id=org.id
    WHERE loc.id=:this->location_id]
    ]></filter></field>

    So when i open the creation form, i need to select a Location, then the org from the location populate the Org field.

    and my field type are like this : 
    <field id="ticketType_id" xsi:type="AttributeExternalKey">
                    <filter>
                        <![CDATA[SELECT CD_TicketType AS t
                        JOIN Organization AS root ON t.org_id=root.id
                        JOIN Organization AS child ON child.parent_id BELOW root.id
                        WHERE child.id = :this->org_id]]>
                    </filter>
                    <sql>ticketType</sql>
                    <target_class>CD_TicketType</target_class>
                    <is_null_allowed>false</is_null_allowed>
                    <on_target_delete>DEL_MANUAL</on_target_delete>
                    <allow_target_creation>false</allow_target_creation>
                </field>
                <field id="ticketType_name" xsi:type="AttributeExternalField">
                    <extkey_attcode>ticketType_id</extkey_attcode>
                    <target_attcode>name</target_attcode>
                </field>
    
     
  • Vincent @ Combodo

    Should the Typology be based on the "org_id" or "user-content-org_id"?
    In the second case, you must change the filter to reference the second field

    child.id = :this->org_id
    child.id = :this->user-content-org_id

     
  • Guillaume Vaillant

    Hello Vincent,

    Oups it's a small typo, this is the correct field on the Ticket :

    <field id="org_id" xsi:type="AttributeExternalKey">
                        <filter><![CDATA[SELECT Organization AS org
                            JOIN Location AS loc ON loc.org_id=org.id
                            WHERE loc.id=:this->location_id]]></filter>
                        <sql>org_id</sql>
                        <target_class>Organization</target_class>
                        <is_null_allowed>false</is_null_allowed>
                        <on_target_delete>DEL_AUTO</on_target_delete>
                        <allow_target_creation>false</allow_target_creation>
                        <dependencies>
                            <attribute id="location_id"/>
                        </dependencies>
                    </field>
                    <field id="org_name" xsi:type="AttributeExternalField">
                        <extkey_attcode>org_id</extkey_attcode>
                        <target_attcode>name</target_attcode>
                    </field>
    
     

    Last edit: Guillaume Vaillant 2 days ago
    • Guillaume Vaillant

       

      Last edit: Guillaume Vaillant 2 days ago
  • Guillaume Vaillant

    Do you think it's because the org_id of my Ticket class is from a parent class ?

    <class id="CD_UserRequest" _delta="define">
                <parent>CD_Ticket</parent>
    

    the org_id field is defined in CD_Ticket

     

Log in to post a comment.