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

CPM code invoke twice

Accepted answer
28
Views
3
Comments
edited Jun 8, 2022 12:02PM in General Technical Discussions 3 comments

Content

Hi Gurus,

We have requirement like, whenever Contact is updated need to set one custom field value and send a notification to an agent. I have deployed the below CPM code on Contact Update. 

My issue is, I have received two email. Please provide your inputs.

 

 

Code Snippet

             <?php
/**
 * CPMObjectEventHandler: Email_Test
 * Package: RN
 * Objects: Contact
 * Actions: Create, Update
 * Version: 1.2
 */
use \RightNow\Connect\v1_2 as RNCPHP;
use \RightNow\CPM\v1 as RNCPM;
 
class Email_Test implements RNCPM\ObjectEventHandler
{
 
    public static function apply($runMode, $action, $contact, $cycles)
    {	    
	 $cid = $contact->ID;
	 if($cid !=null && $cid!="" ){
	  
	 $first_name = $contact->Name->First ;
	 $last_name = $contact->Name->Last ;

 // Our Business Logic - Setting values
	 $contact->CustomFields->c->customer_name = $first_name. " ".$last_name ;
	 	  
	  // Email Notification
			$Email = "[email protected]";

Howdy, Stranger!

Log In

To view full details, sign in.

Register

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