You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

calling cp model (custome script) code from CPM

Received Response
21
Views
1
Comments
edited Jun 13, 2016 8:59PM in Integrations and APIs 1 comment

Content

All,

Can I call a method in my model class written in customer portal (or custom scripts) from CPM script (as shown in the code block)?

Thanks in advance. 

Senthil K

 

 

Version

service cloud Feb-2016

Code Snippet

             /*************  My custom script code resides in cp/models/custom/ ******************/
<?php
namespace Custom\Models;

use RightNow\Connect\v1_2 as RNCPHP,
	RightNow\Libraries\Session,
	RightNow\Utils\Url;

require_once(get_cfg_var("doc_root")."/include/ConnectPHP/Connect_init.phph" );
initConnectAPI();

//API model
class api_model extends \RightNow\Models\Base 
{
	public function getDetails ($incidentId) 
	{
		// 1. perpare the data and make an API call to an external system
		// 2. send the response back to the caller
	}
}


?> 


/************ My CPM Code ******************/

require_once(PATH_TO_MY_CUSTOM_MODEL_IN_CP);

class inc_apicall implements RNCPM\ObjectEventHandler
{

    public static function apply($run_mode, $action, $obj, $n_cycles)
    {

    	$model = new api_model(); 
    	$response = $model->getDetails($obj->ID);
    	// do something

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!