Java API:Event and Task Management

Java API:Event and Task Management

From LongJump Support Wiki

Java API:Event and Task Management
Jump to: navigation, search

The Event and Task Management Java APIs provide the ability to create Appointments, Tasks and to Log Activities.

Contents

addTask

Functions.addTask(String subject, Date dueDate, String ownerId [, Parameters params])
Adds a task with values from params.

Adds a Task to the database. The added task is displayed in the 'Tasks' object.

This API has two signatures, which perform these actions:

The action performed by this API can be performed via the browser interface via the [New Task] in the Related Information section of a record.

In order to associate the task being added to a specific record in an object, add the following key-value pairs to the Parameters object:

Record identifier (task is associated to this record) reference_id
Record identifier (record is in this object)reference_type

The associated task is displayed in the 'Open Activities' section of the record.

In order to use this API with an 'Add' trigger, choose the 'After Triggering Actions' activation sequence, because the record is not available for association with the 'Before Triggering Actions' activation sequence.

Syntax

Result = Functions.addTask(String subject, Date dateDue, String ownerID)

Result = Functions.addTask(String subject, Date dateDue, String ownerID, Parameters params)

Parameters

subject
The subject of the task
dateDue
The date the task is due
ownerID
The identifier of the owner
params
Other task field-value pairs

Return

Result object
Example
This example invokes addTask with three parameters.
String ownerID = "";
// some code to populate the ownerID.
Result addTaskResult = Functions.addTask("Call Acme Solutions", new Date(), ownerID);
// other business logic.
//The Result object contains the ID of the task added using Functions.addTask() API
//Retrieve the ID of the task added using the getID() method of the Result class

This example creates an instance of Parameters and calls addTask with four parameters, adding the task related to a LEAD with the identifier leadID.

String ownerID = "";
String leadID = "";
// some code to populate the ownerID
// some code to populate the leadID
Parameters params = Functions.getParametersInstance();
params.add ("reference_type", "LEAD");
params.add ("reference_id", leadID);
Result addTaskResult = Functions.addTask("Call Acme Solutions", new Date(), ownerID, params);


updateTask

Functions.updateTask(String taskId, Parameters params)
Updates a task with values in params.

Updates a task in the database. In order to update an existing task, pass the record ID of the task to Functions.updateTask() API.

Retrieve the ID of the task to be updated using the getID() method of Result class or Functions.searchRecords()API.

Syntax

Result = Functions.updateTask(String taskID, Parameters params)

Parameters

taskID
The identifier of the task
params
Field-value pairs to update in the task

Return

Result object
Example
This example creates an instance of Parameters, adds a key to it, and then calls updateTask.
String taskID = "";
// Some code to populate the taskID.
Parameters params = Functions.getParametersInstance();
params.add("ownerID", Functions.getEnv(ENV.USER.ID));
// Change the owner of this task to you.
Result updateTaskResult = Functions.updateTask(taskID, params);


deleteTask

Functions.deleteTask(String recordId)
Deletes a task for the taskId.

Retrieve the ID of the task to be deleted using Functions.searchRecords() with specific criteria.

Syntax

Result = Functions.deleteTask(String taskID)

Parameters

taskID
The identifier of the task

Return

Result object
Example
This example calls deleteTask, removing the task identified by taskID.
String taskID = "";
// Some code to populate the taskID, using searchRecords API.
Result deleteTaskResult = Functions.deleteTask(taskID);
//Check the Result object to get details on the execution of the API


addEvent

Functions.addEvent(String subject, String ownerID, Date startDate, int hour, int min, int duration [, Parameters params])
Adds an event with values from params.

The action performed by this API can be performed via the browser interface in New Appointment. The added appointment is displayed in Calendar object.

This API has two signatures:

  • Quick Add event that includes these minimal parameters: subject, owner, startdate, starthour, startminute, duration
  • Add Event which includes additional parameters: related objects, contact, calendar category, repeating information, users to invite to the event, email invitation information
Learn more: Appointments

To associate an appointment with a record in any object, use the Parameters object and add the reference_id and reference_type as key-value pairs.

An appointment that is associated with a specific record in an object is displayed in the 'Open Activities' section of the record the event is related to.

In order to use this API with an 'Add' trigger, choose the 'After Triggering Actions' activation sequence, because the record is not available for association with the 'Before Triggering Actions' activation sequence.


Syntax

Result = Functions.addEvent(String subject, String ownerID,
    Date startDate, int startHour, int startMin, int duration)

Result = Functions.addEvent(String subject, String ownerID,
    Date startDate, int startHour, int startMin, int duration, Parameters params)

Parameters

subject
The subject of the event
ownerID
The identifier of the owner of the event
startDate
The start date of the event, in Date/Time Format
Learn more: Start Date Functionality
startHour
The start hour of the event
startMin
The start minute of the event
duration
The length of the event
params
Other field-value pairs for the event

Return

Result object
Example
This example calls addEvent with seven parameters, adding an event for the leadName on the current date at 10 AM with duration of 1 hour.
String ownerID = "";
String leadName = "";
// Some code to populate the ownerID.
// Some code to populate the leadName
Result addEventResult = Functions.addEvent("Webinar for the lead " + leadName, Functions.getEnv(ENV.USER.ID), new Date(), 10, 00, 60);
// Other business logic goes here


Example
This example creates an instance of Parameters, adds a key it it, and calls addEvent with eight parameters, adding an event for the leadName on the current date at 10 AM with duration of 1 hour.
String ownerID = "";
String leadName = "";
String leadContactID = "";
String leadID = "";
// Add code to populate the ownerID.
// Add code to populate the leadName
// Add code to populate leadContactID
// Add code to populate the leadID
Parameters params = Functions.getParametersInstance();
params.add("contact_id", Functions.getEnv(ENV.USER.ID));
params.add("reference_id", leadID);
params.add("reference_type", "LEAD");

Result addEventResult = Functions.addEvent("Webinar for the lead " + leadName, Functions.getEnv(ENV.USER.ID), new Date(), 10, 00, 60, params);
// Other business logic goes here
//The Result object contains the ID of the appointment added using Functions.addEvent() API
//Retrieve the ID of the appointment added using the getID() method of the Result class


updateEvent

Functions.updateEvent(String eventId, Parameters params)
Updates an event with values in params.

Updates an event in the database. View the updated event in the 'Calendar' object.

In order to update an event, pass the ID of the event to the Functions.updateEvent() API.

When the event is added using the Functions.addEvent() API, retrieve the ID of the event using the Result class. Optionally, use Functions.searchRecords() API to retrieve the ID of the event.

In Data Policies, this API can only be used when the triggering action is 'Update'. Event records cannot be updated when the triggering action is 'Add'.

Syntax

Result = Functions.updateEvent(String eventID, Parameters params)

Parameters

eventID
The identifier of the event
params
Field-value pairs to update in the event

Return

Result object
Example
This example creates an instance of Parameters, adds a key to it, and calls updateEvent.
String eventID = "";
// Some code to retrieve the eventID of an existing event.
// Following code adds description to the Event that has been created.
Parameters params = Functions.getParametersInstance();
params.add("description", "Meeting for next Project with Acme Solutions. Address: 1111 Arguello Blvd. San  Francisco, CA 93093");
Result updateEventResult = Functions.updateEvent(eventID, params);


deleteEvent

Functions.deleteEvent(String eventId)
Deletes the event for the eventId.
To retrieve the ID of the event to be deleted, use Functions.searchRecords() API.

Syntax

Result = Functions.deleteEvent(String eventID)

Parameters

eventID
The identifier of the event

Return

Result object
Example
This example invokes deleteEvent to remove the event identified by eventID.
String eventID = "";
// Some code to populate the eventID, through searchRecords/getRecord API
Functions.deleteEvent(eventID);


logActivity

Functions.logActivity(String subject, String objectId, String id, String activityByID, Parameters params)
Logs an activity in a record; Logged activities appear in the Activity History section of Related Information.

The action performed by this API can be performed via the browser interface in Log Activity.

Syntax

Result = Functions.logActivity(String subject, String objectId, String recordId, String activityByID, Parameters params)

Parameters

subject
Subject of the activity; In the browser UI, the subject is the contents of the Notes field; This argument will populate the contents of the Notes field in the record, and replace any existing data in the field
objectId
Object identifier; Identifies the object this activity is related to; See Object Type Identifier
id
Record identifier; Identifies the record to be updated; The activity associated with this record is updated with Status set to Completed, and % Completed is set to 100%
activityByID
User identifier; The name of the user who has performed this activity
params
Other field-value pairs for the activity

Return

Result object
Example
This example creates an instance of Parameters and calls updateEvent.
Parameters params = Functions.getParametersInstance();
params.add("action_type", "Email");
Result result = Functions.logActivity("Call Primary contact", "ACCOUNT", requestParams.get("id"), Functions.getEnv(ENV.USER.ID), params);
Personal tools