Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,9 @@
<is_null_allowed>true</is_null_allowed>
</field>
<field id="servicesubcategory_id" xsi:type="AttributeExternalKey">
<filter><![CDATA[SELECT ServiceSubcategory WHERE service_id = :this->service_id AND (ISNULL(:this->request_type) OR request_type = :this->request_type) AND status != 'obsolete']]></filter>
<filter><![CDATA[SELECT ServiceSubcategory WHERE service_id = :this->service_id AND status != 'obsolete']]></filter>
<dependencies>
<attribute id="service_id"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep this second explicit dependence (it will be computed anyhow)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not be able to select ServiceSubcategory from another Service. What do you mean with "it will be computed"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Hipska, since about 2 or 3 years, the field dependencies are useless when due to a filter. iTop automatically add the dependency on field specified in the filter. But dependency remains useful when due to a PHP computation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're saying that in the console selecting a Service, and not having this dependency at subcategory, the refresh of that list will happen anyways because :this->service_id is used in the filter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, console and portal

<attribute id="request_type"/>
</dependencies>
<sql>servicesubcategory_id</sql>
<target_class>ServiceSubcategory</target_class>
Expand Down Expand Up @@ -1334,19 +1333,21 @@
// Compute the priority of the ticket
$this->Set('priority', $this->ComputePriority());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as this changes, I would like it to be fully aligned with the recommendation => event based.
Two handlers could be called : EvtComputePriority and EvtComputeRequestType.


// Compute the request_type if not already defined (by the user)
$sType = $this->Get('request_type');
if (is_null($sType) || ($sType === ''))
return parent::ComputeValues();
}]]></code>
</method>
<method id="EvtComputeRequestType">
<static>false</static>
<access>public</access>
<type>EventListener</type>
<code><![CDATA[ public function EvtComputeRequestType(?Combodo\iTop\Service\Events\EventData $oEventData = null)
{
$iSvcSubcat = $this->Get('servicesubcategory_id');
if ($iSvcSubcat != 0)
{
$iSvcSubcat = $this->Get('servicesubcategory_id');
if ($iSvcSubcat != 0)
{
$oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true);
$this->Set('request_type', $oSvcSubcat->Get('request_type'));
}
$oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true);
$this->Set('request_type', $oSvcSubcat->Get('request_type'));
}

return parent::ComputeValues();
}]]></code>
</method>
<method id="DisplayBareRelations">
Expand Down Expand Up @@ -1528,6 +1529,13 @@
}]]></code>
</method>
</methods>
<event_listeners>
<event_listener id="EVENT_DB_BEFORE_WRITE">
<event>EVENT_DB_BEFORE_WRITE</event>
<callback>EvtComputeRequestType</callback>
<rank>0</rank>
</event_listener>
</event_listeners>
<presentation>
<details>
<items>
Expand Down