Menu

Selective method

Kevin
2024-01-16
2024-01-17
  • Kevin

    Kevin - 2024-01-16

    Hello to all,

    I created a new method to implement automatic update on specific field (public_log)
    But with it, I can't create ticket anymore and without error message...

    Here is the method :

    <method id="PublicLogUpdate" _delta="define">
            <static>false</static>
            <access>public</access>
            <type>LifecycleAction</type>
            <code>
              <![CDATA[
                public function PublicLogUpdate() {
                  $sStatus = $this->Get('status');
    
                  $publicLogUpdates = $this->Get('public_log');
                  if ($publicLogUpdates != null) {
                    $publicLogUpdates = $publicLogUpdates->GetAsArray();
                    $lastPublicLogUpdate = reset($publicLogUpdates);
                    $updateAuthorName =  $lastPublicLogUpdate['user_login'];
                    $updateAuthorUserID =  $lastPublicLogUpdate['user_id'];
                    $updateAuthorUserID = intval($updateAuthorUserID);
    
                    $oSearch = new DBObjectSearch('User');
                    $oSearch->AllowAllData();
                    $oSearch->AddCondition('id', $updateAuthorUserID, '=');
                    $oUserProfileSet = new DBObjectSet($oSearch);
    
                    $oUserProfile = $oUserProfileSet->Fetch();
    
                    $oPersonSearch = new DBObjectSearch('Person');
                    $oPersonSearch->AllowAllData();
                    $oPersonSearch->AddCondition('id', $oUserProfile->Get('contactid'), '=');
                    $oPersonSet = new DBObjectSet($oPersonSearch);
    
                    $oPerson = $oPersonSet->Fetch();
    
                    $oPersonTalan = $oPerson->Get('talan_user');
                    if ($sStatus == 'pending' && $oPersonTalan == 'no') {
                      $this->Set('status', 'returned');
                      $this->Set('pending_status', '');
                      $this->Set('status_reason', 'returned');
                    }
                  }
    
                  return true;
                }
              ]]>
            </code>
        </method>
    

    Could you help me to use this method ?
    Maybe can I attach a method to a specific field?

    Kind regards,

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-01-16

    Anything to be seen in the logs of your web server?
    One of the things which seems strange, is that you check of the object $oPersonTalan is a string ('no'). Are you missing an attribute code there or something?

     
  • Kevin

    Kevin - 2024-01-17

    Hello,

    Thanks for your answer.
    I finally found that I forgot to check the HTML content if empty or not for the ticket creation.
    Is now working like a charm :)

    Kind regards,

     

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.