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); } Quote
Blesta Addons Posted November 27, 2014 Report Posted November 27, 2014 have you already created the field in the admin settings ? Quote
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 Quote
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. Quote
Tyson Posted December 1, 2014 Report Posted December 1, 2014 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); Quote
lawrence-ytz Posted December 3, 2014 Author Report Posted December 3, 2014 Thanks, that solved it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.