Hi! I'm Cathy, a Web Designer/Developer/WordPress Fanatic/Salesforce.com Aficionada. I'm from the Philippines and now based in Singapore ...

Archive for the 'Blogging' Category


Sending Email Notification for Task Owner via Apex Trigger

Published by under Blogging,Salesforce.com on Tuesday, March 15th, 2016 at 4:29 pm

I have this business requirement which is when a Salesforce record is inserted and has this specific status, it will auto-create a task and notify the assigned owner via email that he has a new task. So I’ve written a trigger to automate it, during testing I saw that the task has been created and it properly assigns the user until I noticed that it’s not actually sending a notification email unlike when you create a task manually using the standard UI.

I consulted Mr. Google and I stumbled upon this 2-year old developer forum post which discusses the same issue, I tried out the sample code and it seems to work correctly.

For simplicity’s sake, I will be using the standard Opportunity object for the sample code.

Here’s the code snippet:

Trigger:

trigger OpportunityTrigger on Opportunity (before insert, before update, after insert, after update) 
{
   if(trigger.isAfter)
   { 
      if(trigger.isInsert)
      {
         // TriggerHelper is a separate utility class where you can store your static variables 
         // This is used to prevent trigger recursions when there are workflow updates
         if(TriggerHelper.bAfterInsertRun == null) 
         {
            OpportunityHandler.createTask(trigger.new);
            TriggerHelper.bAfterInsertRun = true; // flag the static variable so that it will execute this block of code only once
         }
      }
   }
 ...
}

Class Handler:

public without sharing OpportunityHandler
{
    public static void createTask(List<Opportunity> triggerNew)
    {
       List<Task> listTasksToInsert = new List<Task>();
 
       for(Opportunity objOppty: triggerNew)
       {
           if(objOppty.StageName == 'Follow Up')
           {
              Task newTask = new Task();
              newTask.WhatId = objOppty.Id;
              newTask.Type = 'Follow Up';
              newTask.Description = 'Please follow up this opportunity';
              newTask.Priority = 'Normal';
              newTask.IsReminderSet = true;
              newTask.ReminderDateTime = System.now().addHours(2);
              newTask.Status = 'Not Started';
              newTask.Subject = 'You have a task';
              newTask.ActivityDate = date.Today(); //Due Date
              newTask.OwnerId = Userinfo.getUserId();
              listTasksToInsert.add(newTask);
           }
        }
 
        try 
        {
            if(listTasksToInsert.size() < 0)
            {
               List<Id> listInsertedTaskIds = new List<Id>();
 
               Database.SaveResult[] srList = Database.insert(listTasksToInsert, false);
 
               for(Database.SaveResult sr: srList)
               {
                  if(sr.isSuccess())
                  {
                     listInsertedTaskIds.add(sr.getId());
                  }
               } 
               triggerTaskNotification(listInsertedTaskIds); 
           }
       } 
       catch(DMLException ex)
       {
          system.debug('error : ' + ex.getMessage());
       }
    }
 
    // Mark this method as a future call to prevent it from sending the email twice
    @future 
    public static void triggerTaskNotification(List<Id> taskIds)
    {
       List<Task> taskClone = [Select Id From Task Where Id=:taskIds];
       //Set EmailHeader.triggerUserEmail to true
       Database.DMLOptions dmlo = new Database.DMLOptions();
       dmlo.EmailHeader.triggerUserEmail = true; 
       System.debug('##taskClone: ' + taskClone); 
       //Update Task 
       database.update(taskClone, dmlo);
    }
}

Feel free to comment if it does work or not. 🙂

No responses yet

New Trailhead Release: Navigate the Salesforce Advantage

Published by under Blogging,Salesforce.com on Thursday, March 3rd, 2016 at 11:54 pm

Salesforce has just launched a new Trailhead trail named “Navigate the Salesforce Advantage” which consists of four modules. The objective of this trail is to walk you through Salesforce’s key differentiators that drive their success including their core values, innovative technology, and vibrant ecosystem.

For those who haven’t heard about Trailhead, it is the fun and easier way to learn Salesforce. It is an interactive learning path through the basic building blocks of the Salesforce Platform where you can test your knowledge through challenges, earn points and badges to celebrate your achievements. If you want to learn more about Salesforce, check out this Trailhead link to start your journey.

Now, let’s take a deeper look into each of the modules of the new trail.

trailhead_module_advantage_salesforce_success_model

Salesforce Success Model – Learn who Salesforce is and our vision for driving customer success.

Units: (1) Getting to Know Salesforce; (2) Introducing our Four Core Differentiators – (Innovation, Customer Success, Leadership, Giving Back with 1-1-1)

 trailhead_module_advantage_salesforce_cloud_benefits

Salesforce Cloud Benefits  – Understand the flexibility of a “complete” CRM that evolves with your business needs.

Units: (1) Succeeding with a Complete CRM; (2) Propelling Your Business with the Cloud

 trailhead_module_advantage_salesforce_technology_basics

Salesforce Technology Basics – Get a peek under the hood of our core technology model based on trust and innovation.

Units: (1) Getting Behind the Trusted Cloud; (2) Learning the Value of Multitenancy; (3) Understanding the Power of Metadata; (4) Experiencing Fast App Development and Customization

 trailhead_module_advantage_salesforce_ecosystem

Salesforce Ecosystem – Witness the awesomeness of our incredible partner ecosystem and customer community.

Units: (1) Leveraging our Community, Resources, and Events; (2) Stopping, Collaborating, and Listening;

 

This new trail is beneficial to everyone. It is a great resource for us who have been working in the platform for years and frequently asked by our friends and relatives about what our job is all about.
More importantly, it gives those who are new to Salesforce a great overview of the company, product, technology and the platform ecosystem.

If you are already curious enough to know what sets Salesforce apart from other CRM or on-premise/cloud platforms, head on to Trailhead now!

 

No responses yet

Salesforce.com Summer ’15 Maintenance Exam Q & A

Published by under Blogging,Salesforce.com on Wednesday, July 22nd, 2015 at 5:06 am

Salesforce.com Force.com Developer Summer ’15 Maintenance Exam Test Questions & Answers

  1. Which component can be included in a Lightning page built using the Lightning App Builder? Answers: A, D
    1. Third-party components from the AppExchange.
    2. The Twitter Standard Component.
    3. The Map Standard Component.
    4. The Recent Items Standard Component.
  2. What is a capability of Chatter feed post editing? Answer:  C, D
    1. Group owners can edit system-generated posts in Chatter groups.
    2. Record owners can see previous versions of an edited post.
    3. Users can edit the text of their own Chatter posts.
    4. Record owners can edit other users’ posts on records they own.
  3. What is a capability of Chatter Files? Answers:  A, D
    1. Files can be synced from Chatter to a folder in a local directory.
    2. Users can use @mentions to share files in content libraries.
    3. Private content may only be shared in private Chatter groups.
    4. All content files from content libraries can be synced in Chatter.
  4. What is a capability of Chatter groups? Answers:  B, C
    1. Administrators can assign non-unique names to any Chatter group.
    2. Administrators can choose which custom object records can be added to groups.
    3. Chatter group owners can edit other users’ posts in groups they own.
    4. Chatter group owners can write a group description of any length.
  5. The VP of Sales wants sales reps to be able to quickly create a new opportunity record automatically related to an existing account. This should only be available in the Salesforce1 mobile app. Answers:  B
    1. The Quick Actions section of the Account page layout.
    2. The Salesforce1 Action Bar section of the Account page layout.
    3. The Mobile Card section of the Account page layout.
    4. The Salesforce1 Action Bar section of the Opportunity page layout.

No responses yet

Salesforce.com Spring ’15 Maintenance Exam Q & A

Published by under Blogging,Salesforce.com on Wednesday, May 6th, 2015 at 10:07 pm

Salesforce.com Force.com Developer Spring ’15 Maintenance Exam Test Questions & Answers

  1. What action types are supported with Lightning Process Builder? Answers: A, C
    1. Post to Chatter
    2. Outbound Message
    3. Create a Record
    4. Create a Field
  2. What is a capability of report notifications? Answer:  B, D
    1. Users can configure automatic report notifications for public groups.
    2. Users can schedule how often notifications are sent for each report.
    3. Users can schedule report notifications for their subordinates.
    4. Users can subscribe to reports and set the notification criteria.
  3. How can Lightning Process Builder be used to automate business processes? Answers:  A, D
    1. Create an order renewal when an opportunity is won.
    2. Prevent users from deleting accounts with open opportunities.
    3. Define the steps and approvers in an approval process.
    4. Send an email when a case has been open for 30 days.
  4. How can an administrator make the Manager Groups feature available for use? Answers:  C
    1. Add the Manager Groups permission to selected profiles.
    2. Enter a request for Salesforce to enable Manager Groups.
    3. Enable Manager Groups under Organization-Wide Defaults.
    4. Create an unlisted Chatter group for managers.
  5. What is a true statement about the Analytics Cloud? Answers:  C, D, E
    1. It requires installation of a managed package.
    2. It synchronizes with Salesforce reporting.
    3. It analyzes data from Salesforce and external sources.
    4. It consumes structured, semi-structured, and unstructured data.
    5. It is accessible on iOS mobile devices.
  6. What is a capability of sharing using the Manager Groups feature? Answers:  A, B
    1. Users can share records with the Manager Group through manual sharing.
    2. Users can share records up or down their management chain.
    3. Users with any Salesforce license type can be included in a Manager Group.
    4. Users can add Manager Groups to other groups for sharing purposes.

No responses yet

Salesforce.com Winter ’15 Maintenance Exam Q & A

Published by under Blogging,Salesforce.com on Saturday, January 10th, 2015 at 12:30 pm

Salesforce.com Force.com Developer Winter ’15 Maintenance Exam Test Questions & Answers

Note: Questions and answers may not be in this order. Once again, I’m not giving the assurance that my answers are 100% correct but this made me pass the maintenance exam. Good luck! 🙂

  1. A tabular report can be used as the source report for which Dashboard component? Answers: D
    1. Metric
    2. Stacked Bar Chart
    3. Gauge
    4. Table
  2. Users at Universal Containers often need to update the Status and Amount of an opportunity using the Salesforce1 mobile application. How can this common update be expedited? Answer:  A, D
    1. Create a custom action on the Opportunity object using a Visualforce page.
    2. Create a mobile-only page layout for the Opportunity object.
    3. Create a global update action on the Chatter feed.
    4. Create an object-specific update action on the Opportunity object.
  3. What is a feature of unlisted groups in Chatter? Answers:  A, C
    1. Users with the Manage Unlisted Groups permission can access unlisted groups.
    2. Users can ask for permission to join unlisted groups.
    3. Members of an unlisted group can view the group in list views and search results.
    4. Users with the Modify All Data permission can access unlisted groups.
  4. What is a capability of Advanced Setup Search? Answers:  A, C
    1. Search for individual Setup items, such as workflow rules, by name.
    2. Bookmark specific items listed in the Setup search results.
    3. See which object an item is associated with in the Setup search results.
    4. Search for a specific file stored in the Shared Documents folder.
  5. Universal Containers uses a custom object to track open job positions and would like to send an automatic email to the hiring manager when a position is moved to the closed stage. What can be used to accomplish this? Answers:  A
    1. Workflow rule
    2. Auto-response rule
    3. Escalation rule
    4. Cross-object formula

One response so far

Next »

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: