Jump to content

Recommended Posts

Posted

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);
  
}
Posted

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

Posted

 

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);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...