How to add a custom row action?

Hi,
I am using the below code to insert eLoc into to table offices if Office is not existing in it.
But I am getting this error: "‘copy_to_office’ not found "

     // Page Load event
     function Page_Load() {
         global $Language;

         // Add custom action button to the toolbar
         $item = &$this->OtherOptions["addedit"]->Add("Copy_to_Office");
         $item->Body = "<a class=\"btn btn-default ew-add-edit\" title=\"" . $Language->phrase("Copy to Office") . "\" data-caption=\"" . $Language->phrase("Copy eLoc to Office") . "\" href=\"#\" onclick=\"ew.submitAction(event,      {f:document.futpslist, action: 'copy_to_office'}); return false;\">" . $Language->phrase("Copy to Office") . "</a>";
         $item->Visible = TRUE; // Ensure the action is visible
     }

     // Row Custom Action event
     function Row_CustomAction($action, $row) {
         if ($action == "copy_to_office") {
             $eLoc = $row['eLoc'];
        
             // Check if the eLoc already exists in the Offices table
             $sql = "SELECT COUNT(*) AS cnt FROM offices WHERE Office = '" . AdjustSql($eLoc, $this->Dbid) . "'";
             $result = ExecuteRow($sql);

             if ($result['cnt'] == 0) {
                 // Record to insert
                 $rs = ["Office" => $eLoc];

                 // Insert eLoc into Offices table
                 $insertResult = $this->insert($rs);

                 if ($insertResult) {
                     $this->setSuccessMessage("eLoc value successfully inserted into Offices table.");
                 } else {
                     $this->setFailureMessage("Failed to insert eLoc value into Offices table.");
                 }
             } else {
                 $this->setFailureMessage("eLoc value already exists in Offices table.");
             }
        
             return TRUE; // Return TRUE to continue with other actions
         }
         return FALSE; // Return FALSE if action is not matched
     }

Any idea?
mpol_ch

Please read the Notes section under Example 3 and/or Example 4 of Page_Load server event.