Skip to content

Commit 3e879c6

Browse files
authored
N°4032 - On UserRequest, change proposed service subcategories (#786)
* N°4032 - On UserRequest, service subcategory no more limited by request_type
1 parent 5c6369b commit 3e879c6

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,8 @@
306306
<is_null_allowed>true</is_null_allowed>
307307
</field>
308308
<field id="servicesubcategory_id" xsi:type="AttributeExternalKey">
309-
<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>
310-
<dependencies>
311-
<attribute id="service_id"/>
312-
<attribute id="request_type"/>
313-
</dependencies>
309+
<filter><![CDATA[SELECT ServiceSubcategory WHERE service_id = :this->service_id AND status != 'obsolete']]></filter>
310+
<dependencies/>
314311
<sql>servicesubcategory_id</sql>
315312
<target_class>ServiceSubcategory</target_class>
316313
<is_null_allowed>true</is_null_allowed>
@@ -1334,19 +1331,21 @@
13341331
// Compute the priority of the ticket
13351332
$this->Set('priority', $this->ComputePriority());
13361333
1337-
// Compute the request_type if not already defined (by the user)
1338-
$sType = $this->Get('request_type');
1339-
if (is_null($sType) || ($sType === ''))
1334+
return parent::ComputeValues();
1335+
}]]></code>
1336+
</method>
1337+
<method id="EvtComputeRequestType">
1338+
<static>false</static>
1339+
<access>public</access>
1340+
<type>EventListener</type>
1341+
<code><![CDATA[ public function EvtComputeRequestType(?Combodo\iTop\Service\Events\EventData $oEventData = null)
1342+
{
1343+
$iSvcSubcat = $this->Get('servicesubcategory_id');
1344+
if ($iSvcSubcat != 0)
13401345
{
1341-
$iSvcSubcat = $this->Get('servicesubcategory_id');
1342-
if ($iSvcSubcat != 0)
1343-
{
1344-
$oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true);
1345-
$this->Set('request_type', $oSvcSubcat->Get('request_type'));
1346-
}
1346+
$oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true);
1347+
$this->Set('request_type', $oSvcSubcat->Get('request_type'));
13471348
}
1348-
1349-
return parent::ComputeValues();
13501349
}]]></code>
13511350
</method>
13521351
<method id="DisplayBareRelations">
@@ -1528,6 +1527,13 @@
15281527
}]]></code>
15291528
</method>
15301529
</methods>
1530+
<event_listeners>
1531+
<event_listener id="EVENT_DB_BEFORE_WRITE">
1532+
<event>EVENT_DB_BEFORE_WRITE</event>
1533+
<callback>EvtComputeRequestType</callback>
1534+
<rank>0</rank>
1535+
</event_listener>
1536+
</event_listeners>
15311537
<presentation>
15321538
<details>
15331539
<items>

0 commit comments

Comments
 (0)