Can't modify an array_options of an object with trigger

Hi,

A few weeks ago, I created a trigger in my Dolibarr to create a folder in my Google Drive when I created a project.

If the array_option[“adress_google_drive”] of the project was empty, I used the google service api to create a folder with the project name. And the adress of the folder was going to the array_option[“adress_google_drive”].

In this way, when we modified the project in Dolibarr, the array_option[“adress_google_drive”] was full with the creation of the project, so the google service api did nothing.

It was working very well.

But now, the running is very weird …

On an old project, the google servce api was not used, so it was created without a google drive folder. So the array_option[“adress_google_drive”] was empty.
Normally, the trigger see that, and it created automatically a google drive folder and paste the adress ine the array_option.

But now, the trigger create a google drive folder successfully according the name of the old project, keep the address of the folder in memory (I see that with var_dump), but doesn’t copy it in array_option !!
Here’s a piece of code :

$object->array_options['adress_google_drive'] = $this->createFolder($object->ref.'_'.$object->title, $this->serviceClientGoogle, 'adress_of_a_google_drive_folder'); //createFolder is the function to create the folder

var_dump($object->array_options[‘adress_google_drive’]) and the id of the new folder on google drive is exactly the same.
But, when the dolibarr’s webpage is refreshed, the input is empty !!!

What is the problem ?

Thanks a lot for any kind of help !

Hello,

After putting the value in the extrafield, you need to call $object->update(); to store the value in the database.

Hello,

Thanks for your help.
Unfortunately, it’s not working …

When I write $object->update();. Php gives me an error :
````Uncaught ArgumentCountError: Too few arguments to function Project::update(), 0 passed ```

When I read the project.class.php file, I see this :
public function update($user, $notrigger = 0)

So, I modify my code to put $user like this :
$object->update($user);

But now, I have an infinity loop.

I don’t understand what’s wrong.

Thanks