lawrence-ytz Posted November 26, 2014 Report Share 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 Link to comment Share on other sites More sharing options...
Blesta Addons Posted November 27, 2014 Report Share Posted November 27, 2014 have you already created the field in the admin settings ? Quote Link to comment Share on other sites More sharing options...
lawrence-ytz Posted November 27, 2014 Author Report Share 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 Link to comment Share on other sites More sharing options...
lawrence-ytz Posted November 28, 2014 Author Report Share Posted November 28, 2014 any help? Something was also preventing an external api call from returning a response when creating a client. Quote Link to comment Share on other sites More sharing options...
Tyson Posted December 1, 2014 Report Share 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 Link to comment Share on other sites More sharing options...
lawrence-ytz Posted December 3, 2014 Author Report Share Posted December 3, 2014 Thanks, that solved it. Quote Link to comment Share on other sites More sharing options...
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.