Child Record Creation


After creating a trigger on Opportunity object as it was done previously,see code below.

1trigger OpportunitiesTrigger on Opportunity (after delete, after insert, after undelete, after update) {
2    forvendi.BreezzApi.TRIGGERS.handle();
3}

Next configure Breezz Trigger on lead object for after insert actions and deploy. Lastly create a new class that will generate a child object, here a task record, after creation of opportunity is committed.

 1public with sharing class CreateTastAfterOpportunity extends forvendi.Step {
 2   
 3    public CreateTastAfterOpportunity() {
 4        super(CreateTastAfterOpportunity.class.getName());
 5    }
 6 
 7    public override Boolean initRecordProcessing(Object record, Object optionalOldRecord) {
 8        // creating new task record related to the incoming object
 9        // use ModificationContext to insert task record
10        SObject sfRecord = (SObject) record;
11        Task task = new Task(
12            Status = 'In Progress',
13            Subject = 'Call',
14            WhatId = sfRecord.Id);
15        getContext().addToInsert(task);
16        return false;
17    }
18}

Upcoming and Overdue Upcoming and Overdue