Menu

Extension overloaded method not being called

Cyro
2024-12-18
2024-12-19
  • Cyro

    Cyro - 2024-12-18

    Hello!

    I'm trying to create an extension to be able to get the last person who emailed a ticket into a field of the user request ticket. I'm using Combodo email synchro and a custom extension to do this. My issue is that the function BeforeUpdateTicket does not seem to be called since I am not getting any updates to error.log or actual updates to the ticket after an email is received. I'm trying to replace the stub implementation: https://github.com/Combodo/itop-standard-email-synchro/blob/94aca081de28f5f6f45fb485cfa171cfcf10837a/datamodel.itop-standard-email-synchro.xml#L908

    Heres the extension:

       <class id="UserRequest">
            <fields>
              <field id="last_updater" xsi:type="AttributeExternalKey" _delta="define">
                <sql>lastupdater_id</sql>
                <target_class>Person</target_class>
                <is_null_allowed>true</is_null_allowed>
                <on_target_delete>DEL_MANUAL</on_target_delete>
                <allow_target_creation>false</allow_target_creation>
              </field>
            </fields>
           <presentation>
              <details>
                <items>
                  <item id="col:col2" _delta="must_exist">
                    <items>
                      <item id="fieldset:Ticket:contact" _delta="must_exist">
                        <items>
                          <item id="last_updater" _delta="define">
                            <rank>31</rank>
                          </item>
                        </items>
                      </item>
                    </items>
                  </item>
                </items>
              </details>
            </presentation>
        </class>
        <class id="MailInboxStandard">
          <parent>MailInboxStandard</parent>
          <methods>
            <method id="BeforeUpdateTicket">
              <static>false</static>
              <access>protected</access>
              <type>Overload-DBObject</type>
              <code><![CDATA[
                protected function BeforeUpdateTicket(Ticket $oTicket, EmailMessage $oEmail, Contact $oCaller)
                {
                  // Get the contact ID
                $contactId = $oCaller->GetKey();
                IssueLog::Info("Caller ID: " . $contactId);
    
                // Set the last_updater field to the contact ID
                $oTicket->Set("last_updater", $contactId);
                }
              ]]></code>
              </method>
          </methods>
        </class>
    

    In the dependencies I've added:

        'dependencies' => array(
            'itop-standard-email-synchro/3.4.4'
        ),
    
     
  • Stephen Abello

    Stephen Abello - 2024-12-18

    Hi Cyro,

    It looks like you're missing a _delta attribute on your <method> element.
    Try adding _delta="redefine" and let us know if it works

    Hope this helps
    Stephen

     
  • Cyro

    Cyro - 2024-12-19

    Heya!

    Thank you, I can't believe I didn't notice that it was missing! It works perfectly now. 😊

     
    😄
    1

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.