function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Katrina_HarshKatrina_Harsh 

Creating Apex Trigger for a task.

Hello,

I am trying to write a Apex Trigger that can populate a custom field (checkbox), so my workflows will function properly.  Right now the workflows function perfect for tasks that are created within Salesforce, however; when tasks are created from Outlook to Salesforce, none of the workflows get triggered.

I have attempted writing the trigger in multiple ways, based on what I have found in research, but none of the options are pulling correctly.  Can anyone provide a solution on how the apex should appear so that when a checkbox is populated to TRUE the workflows will then be triggered?  This way when a task is created in Salesforce or in Outlook, they will automatically populate this checkbox and the workflows will then be dependent on the custom field.

Thanks,

Katrina 
Shashikant SharmaShashikant Sharma
Hi Katrina,

You could read about trigger development here: http://forceschool.blogspot.in/search/label/Apex%20Triggers

In order to make your workflow run. You should have a before insert trigger on Task and  populate the check box value.

Workflow execution happens after the triggers so it should invoke the workflow. Let me know if you face any issues.

Thanks
Shashikant 

 
Katrina_HarshKatrina_Harsh

Thank you Shashikant,

I know that I need to use a "before insert" trigger, but I am having a difficult time writing the entire coding to check the box properly.  Can you tell me if I am on the right track?

User-added image