Java Code Data Policy Examples/Add Appointment On Update Prospect Code Sample

Java Code Data Policy Examples/Add Appointment On Update Prospect Code Sample

From LongJump Support Wiki

Java Code Data Policy Examples/Add Appointment On Update Prospect Code Sample
Jump to: navigation, search

This code is intended for use as part of a Data Policy. It is a complex example of the use of Java code to take a series of actions, each based on the previous code section. For information on the use of this code sample, see: Add Appointment On Update Prospect.

import com.platform.api.*;


public class DataPolicyExamples {

  public void addAppointment(Parameters requestParams) {

    //Get user ID to assign the event
    String ownerID = Functions.getEnv(ENV.USER.ID);

    //Get the name of the Prospect
    String leadName = requestParams.get("name");
     
    //Add Prospect to debug log
    Functions.debug("Prospect name:" + leadName);

    //Get Parameter instance to pass the record details to addEvent
    Parameters params = Functions.getParametersInstance();
    params.add("reference_id", requestParams.get("id"));
    params.add("reference_type", "LEAD");

    //Add the event to the prospect record
    Result result = Functions.addEvent("Online Training scheduled for " + leadName,
        Functions.getEnv(ENV.USER.ID), new Date(), 5, 19, 60, params);

    //check the debug log for the result of the
    Functions.debug("Result of addEvent:" + result.getMessage());
    Functions.debug("Record of the event added:" + result.getID());
    if(result.getCode() != -1)
    {
      //On success - update 'Appointment Id' field in the layout
      //with record_id of the appointment
      requestParams.add("appointment_id", result.getID());
      Functions.debug(
         "Appointment made for the prospect to attend training.\n"
       + "Calendar updated.");
    }
    else
    {
      Functions.debug("Error in adding an appointment to the Prospect.\n"
                     + result.getMessage());  
    }
  } // end method
}// end class
Personal tools