Menu

PrefillSearchForm on AttributeExternalKey

Nico
2021-10-15
2023-01-18
  • Nico

    Nico - 2021-10-15

    Hi,
    I have an AttributeExternalKey in Incidents and UserRequest and want to prefill its searchform.
    I have added this method:

    <method id="PrefillSearchForm" _delta="define">
              <static>false</static>
              <access>public</access>
              <type>Overload-DBObject</type>
              <arguments>
                <argument id="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');
                    }
                  }
                  ]]>
              </code>
            </method>
    

    I can see that prefill works when I try adding a CI via the Tab(Functional CIs) but it's not working on the AttributeExternalKey which also points to the class "FunctionalCI".
    What am I missing?
    Thanks,
    best regards, Nico

     
  • Vincent @ Combodo

    An AttributeExternalKey cannot be prefilled with PrefillSearchForm, but there is a simpler mean, just use the XML tag "filter" on the AttributeExternalKey to define an OQL filter

     
    • Nico

      Nico - 2021-10-15

      Hi,
      thanks for the reply. I already tested it and I think this will be my solution.
      The only bad thing in this solution is that you have to select an other class via the drop-down field, if another selection should be made, because the filter tag disabled the field in the filter tab bar.
      Anyway, I will try this :-)

       
  • Ana María  Gutiérrez González

    Hola.
    I am trying to replicate this and it has no effect. I don't know if I have defined the method in a wrong place.
    Thank you.
    Ana

     
    • Vincent @ Combodo

      Can you be more specific on what you want to achieve?
      Check again the wiki, in general the Searched Class and the class containing the method are different...

       
  • Ana María  Gutiérrez González

    Hi Vincent.
    First, thank you very much for the help.
    You see, what I'm trying to do is behave similar to what occurs when we assign a user to an organization and from then on, only he sees the data associated with that organization. But instead of filtering by organization, I want to filter by certain states.

     
  • Vincent @ Combodo

    Hu Ana,
    In your code the value "No visible" for 'status' is probably not a valid enum code, it expects the code-value not its label

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.