lawrence-ytz Posted November 26, 2014 Report Posted November 26, 2014 I'm trying to set a custom field from with in a plugin when a new client is created. The event is is working, but either the model or method are not. public function getEvents() { return array( // on create client array( 'event' => "Clients.create", 'callback' => array("this", "run") ) // on cancel service ); } public function run($event) { Loader::loadModels($this, array("Clients")); $params = $event->getParams(); $user_id = $params->id; //die( 'hello' ); //the event is firing at the correct time //update custom field $vars = array ( 'field_id' => 3, 'client_id' => 352, 'value' => 1111, ); $this->Clients->setCustomField($vars); }
Blesta Addons Posted November 27, 2014 Report Posted November 27, 2014 have you already created the field in the admin settings ?
lawrence-ytz Posted November 27, 2014 Author Report Posted November 27, 2014 field is already created in the admin. I can also update it via an api call from an external app, just not from within the blesta environment. A bit more info that may be helpfull, I'm trying to execture this from mycustom_plugin.php
lawrence-ytz Posted November 28, 2014 Author Report Posted November 28, 2014 any help? Something was also preventing an external api call from returning a response when creating a client.
Tyson Posted December 1, 2014 Report Posted December 1, 2014 On 11/26/2014 at 10:42 PM, lawrence-ytz said: public function run($event) { ...//update custom field $vars = array ( 'field_id' => 3, 'client_id' => 352, 'value' => 1111, ); $this->Clients->setCustomField($vars); } Method calls from plugins don't function like the API SDK. What I mean is that you do not pass in an array of key/value pairs representing the parameters and their values. Instead, you pass in the parameters directly. i.e. $field_id = 3; $client_id = 352; $value = 1111; $this->Clients->setCustomField($field_id, $client_id, $value);
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now