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