Menu

class[UserRequest] at line 3: could not be found

Dmitry
2024-04-12
2024-11-15
  • Dmitry

    Dmitry - 2024-04-12

    Error loading module "prefill-extension": /itop_design/class[UserRequest] at line 3: could not be found - Loaded modules: dictionaries:1.0, core:1.0, application:1.0, authent-cas:3.1.0, authent-external:3.1.0, authent-local:3.1.0, combodo-autoclose-ticket:1.0.1, combodo-backoffice-darkmoon-theme:3.1.0, combodo-cmdbchange-cleaner:1.0.4, combodo-email-synchro:3.6.0, combodo-password-expiration:1.0.1, combodo-workflow-graphical-view:1.1.0, itop-attachments:3.1.0, itop-backup:3.1.0, itop-config:3.1.0, itop-data-collector-ldap:1.0.7, itop-files-information:3.1.0, itop-object-copier:1.4.3, itop-portal-base:3.1.0, itop-portal:3.1.0, itop-profiles-itil:3.1.0, itop-sla-computation:3.1.0, itop-standard-email-synchro:3.4.2, itop-stencils:1.0.6, itop-structure:3.1.0, itop-themes-compat:3.1.0, itop-tickets:3.1.0, itop-welcome-itil:3.1.0, molkobain-portal-mosaic-service-catalog:1.0.0, templates-base:3.5.1, authent-token:2.1.1, combodo-db-tools:3.1.0, itop-config-mgmt:3.1.0, itop-core-update:3.1.0, itop-datacenter-mgmt:3.1.0, itop-endusers-devices:3.1.0, itop-faq-light:3.1.0, itop-hub-connector:3.1.0, itop-incident-mgmt-itil:3.1.0, itop-knownerror-mgmt:3.1.0, itop-oauth-client:3.1.0, itop-problem-mgmt:3.1.0, itop-request-mgmt-itil:3.1.0, itop-service-mgmt:3.1.0, itop-storage-mgmt:3.1.0, itop-virtualization-mgmt:3.1.0, prefill-extension:1.0.0

     
  • Dmitry

    Dmitry - 2024-04-12

    and module

     
  • Dmitry

    Dmitry - 2024-04-12

    When installing the extension, an error pops up, although I have connected the module that is required for UserRequest

     
  • Guillaume Lajarige

    Hello Dmitry,

    It's most likely that you are missing the <classes> node in your XML. Try this instead:

    <?xml version="1.0" encoding="UTF-8"?>
    <itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
        <classes>
            <class id="UserRequest" _delta="must_exist">
                <methods>
                    <method id="PrefillCreationForm" _delta="define">
                        <static>false</static>
                        <access>public</access>
                        <type>Overload-DBObject</type>
    
                        <code><![CDATA[public function PrefillCreationForm(&$aContextParam)
                      {       
                            $oUser = UserRights::GetUserObject();
                            $this->Set('org_id',$oUser->Get('org_id'));
                            $this->SetIfNull('caller_id', $oUser->Get('contactid'));
                      }]]>
                        </code>
                    </method>
                </methods>
            </class>
        </classes>
    </itop_design>
    

    Hope it helps,
    Guillaume

     
    • Dmitry

      Dmitry - 2024-04-15

      Yes, my bad, thanks for the help

       
      • Guillaume Lajarige

        Glad you could fix it :)

         
  • Teemu

    Teemu - 2024-11-14

    Hi. I have similar problem but <classes> do not fix the problem. I'm trying to prefill the servicesubcategory (and servicecategory) field in UserRequest Form in Portal side.

    An error occured while processing the PHP files of the data model:
    Error loading module "customize-portal": /itop_design/classes/class[UserRequest] at line 4: could not be found or marked as removed 
    
    <?xml version="1.0" encoding="UTF-8"?>
    <itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
      <classes>
        <class id="UserRequest" _delta="must_exist">
          <methods>
            <method id="PrefillCreationForm" _delta="define">
              <static>false</static>
              <access>public</access>
              <type>Overload-DBObject</type>
              <code><![CDATA[
                public function PrefillCreationForm(&$aContextParam)
                {
                    parent::PrefillCreationForm($aContextParam);
    
                    $iSubcategoryId = 5;
    
                    // Set a specific servicesubcategory_id
                    $this->Set('servicesubcategory_id', $iSubcategoryId);
    
                    // Get the ServiceSubCategory object to also set the service_id
                    $oSubcategoryObject = MetaModel::GetObject('ServiceSubCategory', $iSubcategoryId, false);
    
                    if ($oSubcategoryObject) {
                      $this->Set('service_id', $oSubcategoryObject->Get('service_id'));
                    }
                }
              ]]></code>
            </method>
          </methods>
        </class>
      </classes>
      <!-- Portal module design -->
      <module_designs>
        <module_design id="itop-portal" xsi:type="portal">
          <bricks>
          ...
    

    I also have a folder classes and UserRequestExtended.php file in side it.

    <?php
    
    class UserRequestExtended extends UserRequest
    {
      public function PrefillCreationForm(&$aContextParam)
      {
        parent::PrefillCreationForm($aContextParam);
    
        $iSubcategoryId = 5;
    
        // Set a specific servicesubcategory_id
        $this->Set('servicesubcategory_id', $iSubcategoryId);
    
        // Get the ServiceSubCategory object to also set the service_id
        $oSubcategoryObject = MetaModel::GetObject('ServiceSubCategory', $iSubcategoryId, false);
    
        if ($oSubcategoryObject) {
          $this->Set('service_id', $oSubcategoryObject->Get('service_id'));
        }
      }
    }
    

    Any help appreciated 🙏

     
  • Vincent @ Combodo

    In your extension, file module.xxx.php in the dependecies , have you said that your module must be loaded AFTER the module which brinks the User Request class ?

    By the way, the first implementation in XML is enough. I don't understand the second one which would have no effect

     
    • Teemu

      Teemu - 2024-11-15

      Thank you for the answer. I didn't realize that I needed to set dependencies like that. Adding itop-request-mgmt-itil solved the problem.

       

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.