Now I want to use this filter like the function PrefilledSearchForm for a linked class.
So it should be possible to remove this filter to maybe choose other CIs too.
Is this possible? I think these search forms are not handled by the "PrefilledSearchForm" method.
Thanks for any hint.
Best regards, Nico
There is no way to desactivate the filter in the search.
The PrefilledSearchForm is not called for an ExternalKey, just for feeding an AttributeLinkedSetIndirect.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the hint Vincent.
I found out that I can dynamically set a filter by just creating a new ExtKeyWidget through JS:
oACWidget_2_***=newExtKeyWidget('***','FunctionalCI',"SELECT `FunctionalCI` FROM FunctionalCI AS `FunctionalCI` WHERE finalclass = 'ApplicationSolution'",'Application Solution',false,oWizardHelper,'***',false,true);
This helps me to build "fast-filters" depending on choosed options, in this case in a UR/Incident.
Best regards, Nico
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Pierre,
when creating a new UserRequest or Incident I am using the "PrefillSearchForm"-Method to set filters for adding FunctionalCIs to the ticket.
If already a caller is set, the searchform only shows the caller-CIs and in addition application solutions (of course both together make no sense, so the user has to remove one of both filters, depending on what he wants to choose - working fine so far):
<methodid="PrefillSearchForm"_delta="define"><static>false</static><access>public</access><type>Overload-cmdbAbstractDBObject</type><arguments><argumentid="1"><type>reference</type><mandatory>true</mandatory></argument></arguments><code><![CDATA[ public function PrefillSearchForm(&$aContextParam) { if($aContextParam['dest_class'] == 'FunctionalCI' && $aContextParam['origin'] == 'console') { $aContextParam['filter']->ResetCondition(); $aContextParam['filter']->AddCondition('finalclass', 'ApplicationSolution', 'IN'); if (!null == $this->Get('caller_id')) { $aCIIDs = array(); $OQL= 'SELECT FunctionalCI AS fci JOIN lnkContactToFunctionalCI AS lnk ON lnk.functionalci_id = fci.id WHERE lnk.contact_id = "'.$this->Get('caller_id').'"'; $NM_oSearch = DBObjectSearch::FromOQL($OQL); $NM_oSet = new DBObjectSet($NM_oSearch,array()); while($NM_oSetr = $NM_oSet->Fetch()) { $iCIID = $NM_oSetr->Get('id'); array_push($aCIIDs, $iCIID); } if (!empty($aCIIDs)) { $aContextParam['filter']->AddCondition('id', $aCIIDs, 'IN'); } } } } ]]></code></method>
Now I added a new attribute of type AttributeExternalKey. Here a kind of "primary CI" should be added (I also installed a function to add this selected CI to the functionalcis_list when creating the ticket).
But as Vincent explained it is not possible to set these filters here too.
So I tried to find a solution and just added JS functions to insert some buttons (see screenshot).
If these buttons are clicked the new ExtKeyWidget will be set in JS and the searchform is triggered, applied the OQL statement set in the widget.
The only drawback is that this filter is not shown in the searchform but it's not very important in my case.
Hi,
for a new attribute of type "AttributeExternalKey" I set a filter in the datamodel XML file.
Target-class is FunctionalCI and the filter is
Now I want to use this filter like the function PrefilledSearchForm for a linked class.
So it should be possible to remove this filter to maybe choose other CIs too.
Is this possible? I think these search forms are not handled by the "PrefilledSearchForm" method.
Thanks for any hint.
Best regards, Nico
There is no way to desactivate the filter in the search.
The PrefilledSearchForm is not called for an ExternalKey, just for feeding an AttributeLinkedSetIndirect.
Thanks for the hint Vincent.
I found out that I can dynamically set a filter by just creating a new ExtKeyWidget through JS:
This helps me to build "fast-filters" depending on choosed options, in this case in a UR/Incident.
Best regards, Nico
Hello Nico, can you explain your use case ? You might be using a complicated solution whearas something simplier could be implemented ?
Hi Pierre,
when creating a new UserRequest or Incident I am using the "PrefillSearchForm"-Method to set filters for adding FunctionalCIs to the ticket.
If already a caller is set, the searchform only shows the caller-CIs and in addition application solutions (of course both together make no sense, so the user has to remove one of both filters, depending on what he wants to choose - working fine so far):
Now I added a new attribute of type AttributeExternalKey. Here a kind of "primary CI" should be added (I also installed a function to add this selected CI to the functionalcis_list when creating the ticket).
But as Vincent explained it is not possible to set these filters here too.
So I tried to find a solution and just added JS functions to insert some buttons (see screenshot).
If these buttons are clicked the new ExtKeyWidget will be set in JS and the searchform is triggered, applied the OQL statement set in the widget.
The only drawback is that this filter is not shown in the searchform but it's not very important in my case.
Thanks for the explanations ! Indeed for your use case I don't think we have a solution for now.
Great work, congrats !