Sidebar

Using iTop

Creating your iTop

iTop Customization

"How to" examples
DataModel

User Interface

Automation & Ticket management

Portal Customization

:: Version 3.2.0 ::

Portal: Creating Tickets for others

Prerequisite: You must be familiar with the Syntax used in Tutorials, have already created an extension and be familiar with the XML portal logic.

learning:
Changing Ticket caller in Portal
level:
Intermediate
domains:
XML, Access rights, Portal
min version:
2.7.0

Let's allow a Power User to create Ticket in the Portal for other Person than himself:
Usecase: We want Power Users to be able to create Ticket in iTop Portal for any other Person in their Organization.

For that you will need to:

  • Have an iTop system with the enhanced portal installed,
  • Have access to an account having the Portal User and Power User profiles,
  • Have a way to modify the datamodel definition (creating an extension or with ITSM Designer)

In order to achieve the above usecase, we will need to change the default settings of the Portal. This settings is purely defined in the XML structure, so we just need to alter it. For this:

  • Understand the XML portal logic
  • Retrieve the default Portal model in the file <itop>/data/datamodel-production.xml located on your installed iTop.
  • Check the Customer portal XML Reference for explanation on the XML structure and tags
  • Write XML code to alter the default Portal model

If we want to limit this possibility to Power user only, then, we must change in the XML Datamodel the filter for the field caller_id of the class Ticket. The filter is an OQL query, which defines the UI proposed callers, based on other Ticket fields and/or the current user.

XML Portal Form

For our usecase we will just need to modify the Ticket creation form, and in that form, just redefine the twig tag. Because the XML tags below the twig have to id, you must always redefine the full content of that tag.

itop_design / module_designs
   <module_design id="itop-portal" _delta="must_exist">
      <forms>
        <form id="ticket-create" _delta="must_exist">
          <twig _delta="redefine">
            <div class="row">
              <div class="col-sm-6">
                <div class="form_field" data-field-id="service_id" data-field-flags="mandatory"></div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="servicesubcategory_id" data-field-flags="mandatory"></div>
              </div>
            </div>
            <div id="service_details_placeholder">
              <div class="form_field" data-field-id="service_details"></div>
            </div>
            <div class="row">
              <div class="col-sm-4">
                <div class="form_field" data-field-id="caller_id"></div>
              </div>
              <div class="col-sm-4">
                <div class="form_field" data-field-id="impact"></div>
              </div>
              <div class="col-sm-4">
                <div class="form_field" data-field-id="urgency"></div>
              </div>
            </div>
            <div>
              <div class="form_field" data-field-id="title"></div>
              <div class="form_field" data-field-id="description"></div>
              <div class="form_field" data-field-id="contacts_list"></div>
            </div>
          </twig>
        </form>
      </forms>
    </module_design>
This change on a form applies for all Portal users, as a form cannot be limited to a set of Profiles. So simple Portal user can also create User Request for other Person in their Organization.

caller_id filter

It is possible to change the above limitation by setting this quite complex filter tag on the Ticket.caller_id, assuming you have a iTop 2.7.0 or above

Working query
SELECT Person WHERE 
(org_id=:this->org_id 
AND 
  (:current_contact_id NOT IN (SELECT Person AS p 
                           JOIN USER AS u ON u.contactid=p.id
                           JOIN URP_UserProfile AS uup ON uup.userid=u.id 
                           JOIN URP_Profiles AS up ON uup.profileid=up.id 
                           WHERE up.name='Portal user' AND p.id = :current_contact_id
                           ) 
  OR :current_contact_id IN (SELECT Person AS p 
                           JOIN USER AS u ON u.contactid=p.id
                           JOIN URP_UserProfile AS uup ON uup.userid=u.id 
                           JOIN URP_Profiles AS up ON uup.profileid=up.id 
                           WHERE up.name='Portal power user' AND p.id = :current_contact_id
                           )
  )
)
OR (org_id=:this->org_id AND id=:current_contact_id)

Also the below query seems smaller, it does not work. 🚧 Root cause still under investigation

Not working filter
SELECT Person WHERE 
(org_id=:this->org_id 
AND 
  (:current_user->id NOT IN (SELECT USER AS u 
                           JOIN URP_UserProfile AS uup ON uup.userid=u.id 
                           JOIN URP_Profiles AS up ON uup.profileid=up.id 
                           WHERE up.name='Portal user' AND u.id = :current_user->id
                           ) 
  OR :current_user->id IN (SELECT USER AS u 
                           JOIN URP_UserProfile AS uup ON uup.userid=u.id 
                           JOIN URP_Profiles AS up ON uup.profileid=up.id 
                           WHERE up.name='Portal power user' AND u.id = :current_user->id
                           )
  )
)
OR (org_id=:this->org_id AND id=:current_contact_id)
3_2_0/customization/portal_howto_change_caller.txt · Last modified: 2024/09/10 10:25 by 127.0.0.1
Back to top
Contact us