Sidebar

Using iTop

Creating your iTop

iTop Customization

"How to" examples
DataModel

User Interface

Automation & Ticket management

Portal Customization

:: Version 3.2.0 ::

Force a field to be mandatory by lifecycle

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

learning:
Force a field to be filled on some state/transition
level:
Intermediate
domains:
XML, PHP, Constrain, Lifecycle
min version:
2.1.0

This use case is just one way of forcing a field to be provided.

For those use cases, we will use UserRequest class, because it has a lifecycle. When an object has a lifecycle, iTop datamodel allow to specify on a Transition and on a State which fields must be required.

Flags on lifecycle applies to Console and Portal, but do not force the field to be provided when object is created/modified using CSV import, DataSynchro or API REST/JSON

with the Designer

Prerequisite: You must be a Combodo's customer

Mandatory on transition

Let's impose that a Service must be documented when a User Request is moved from state New to state Assigned.
That move is called a transition and is uniquely identified by the initial state and the stimulus applied.

Can be done in a few clicks with no code writing

Mandatory on a state

In this usecase we want to be sure that all UserRequest in state Assigned have a Service defined.

When the “mandatory” flag is defined at the state level, then it automatically applies to all transitions ending on that state, even if not specified at the transition level.

Again this is only a few clicks with no code writing


with an iTop Extension

Prerequisite: You must have already created an iTop extension.

Mandatory on transition

Let's impose that a Service must be documented when a User Request is moved from state New to state Assigned.
Here is the XML code you must write for this:

itop_design / classes
    <class id="UserRequest">
      <lifecycle>
        <states>
          <!-- For User Request in State New... -->
          <state id="new">
            <transitions>
              <!-- On the transition, trigger by ev_assign stimulus... -->
              <transition id="ev_assign" _delta="must_exist">
                <flags>
                  <!-- We want to force the Service... -->
                  <attribute id="service_id" _delta="define" >
                    <!-- to be provided -->
                    <mandatory/>
                  </attribute>
                </flags>
              </transition>
            </transitions>
          </state>
        </states>
      </lifecycle>
    </class>

Mandatory on a state

In this usecase we want to be sure that all UserRequest in state Assigned have a Service defined.

itop_design / classes
    <class id="UserRequest" _created_in="itop-request-mgmt-itil" _delta="must_exist">
      <lifecycle>
        <states>
          <state id="assigned" _delta="must_exist">
            <!-- setting no _delta is equivalent to _delta="merge" -->
            <flags>
              <!-- Here we assume that no other extension nor the default datamodel... -->
              <!-- has set flags on field 'service-id' for state 'assigned' already -->
              <attribute id="service_id" _delta="define>
                <mandatory/>
              </attribute>
            </flags>
          </state>
        </states>
      </lifecycle>
    </class>

Migration: No visible effect on setup, but objects not compliant can no more be modified in the Console or Portal, until a Service is provided. Create an audit rule to retrieve objects not compliant to this new constrain and fix them.

3_2_0/customization/mandatory-on-transition.txt · Last modified: 2024/06/20 17:28 (external edit)
Back to top
Contact us