Menu

DisplayBareRelation not working

2017-07-14
2017-11-21
  • Marvin Schendel

    Marvin Schendel - 2017-07-14

    Hello,

    I´m using in the Class Software the DisplayBareRelation-Method to show the connection of User and Software.

    <method id="DisplayBareRelations" _delta="define">
                        <static>false</static>
                        <access>public</access>
                        <type>Overload-cmdbAbstractObject</type>
                        <code><![CDATA[ function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
        {
            parent::DisplayBareRelations($oPage, $bEditMode);
    
            if (!$bEditMode)
            {
                if (MetaModel::IsValidClass('Software'))
                {
                    //Search for User
                    $oPage->SetCurrentTab(Dict::S('Class:Software:UserList'));
                    $iSoftwareID = $this->GetKey();;
                    $oUserSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT si,p FROM SoftwareInstance AS si JOIN PC AS pc ON si.system_id=pc.id JOIN lnkContactToFunctionalCI AS lnk ON lnk.functionalci_id=pc.id JOIN Person AS p ON lnk.contact_id=p.id WHERE si.software_id=$iSoftwareID"));
                    $iNumberU=$oUserSet->count();
                    if ($iNumberU > 0)
                    {
                        $oPage->SetCurrentTab(Dict::S('Class:Software:UserList')." ($iNumberU)");
                    }
                    else
                    {
                        $oPage->SetCurrentTab(Dict::S('Class:Software:UserList'));  
                    }           
                    self::DisplaySet($oPage, $oUserSet, array ('menu' => false));
                }
            }
        }]]></code>
                    </method>
    

    The problem is, that i can see in the Tab only the SoftwareInstance and not the Persons too (SELECT si,p). If I test the Query in Admin-Tools it works perfectly.
    Any ideas what I can do?

     
  • APO

    APO - 2017-11-21

    Put a $oPage->Rewind(); before the if statement. Apparently count leaves the object pointer at the end of the object. The SetCUrrentTab() function has no reference as the pointer is pointing to null. (the end). Maybe :)

     

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.