Giovanni Marazzi

SugarQuery - Problem changing a custom field with scheduler based on another one( custom field)

Discussion created by Giovanni Marazzi on Jan 11, 2018
Latest reply on Jan 15, 2018 by Francesca Shiekh
Branched from an earlier discussion

I updated my SugarQuery to this:

 

     $sqClient = new SugarQuery();
    
     $sqClient->select(array('id', 'lftm_data_ativacao_c'));
     $sqClient->from(BeanFactory::newBean('Contacts'));
     $sqClient->where()->equals('lftm_data_ativacao_c', NULL);
    
     $resultClient = $sqClient->execute();
    
     foreach($resultClient as $rowClient) {
          $Client = BeanFactory::retrieveBean('Contacts', $rowClient['id'], array('disable_row_level_security' => true));
          $link = 'ger01_gerenciamentocliente_contacts';
          if($Client->load_relationship($link)) {
               $minDate = NULL;
               foreach($Client->$link->getBeans() as $gCliente) {
                    if($minDate = NULL) {
                         $minDate = $gCliente->lftm_mes_referencia_c;
                    } else {
                         if($minDate > $gCliente->lftm_mes_referencia_c) {
                              $minDate = $gCliente->lftm_mes_referencia_c;
                         }
                    }
               }
               $Client->lftm_data_ativacao_c = $minDate;
          }
     }
    

 

My contacts field(lftm_data_ativacao_c) is not changing and this message is showing on log:

 

CSRF: attack vector detected, missing form token field
CSRF: auth failure for ModuleBuilder -> savetablesort

Thanks beforehand for the huge help you have been giving to me.




Edit: lftm_data_ativacao_c is datetime

Outcomes