Thursday 12 February 2015

Salesforce Magic Tricks: Case & Report

In my previous post, I had shared some useful tricks to conquer the world using Standard Salesforce objects like Lead and Account. True to my promise, I am back with a few more tricks up my sleeve, this time for Case and Report object.

Case: Flagging neglected cases

Without a shade of doubt, servicing our clients is of utmost importance, especially if you are in the service industry. That is why when one of your customers raises an issue or a query through the portal, your service desk person raises a case immediately, noting and monitoring his problems, resolutions and all the communication within that case history. But what happens if your customer has not responded to your query for details? Or in the flood of all the cases your agent has to handle, (imagine multiple updates from each single case and multiple cases assigned to each agent!) he has overlooked one of the open cases simply because the client did not respond for quite some time.

It is important that as a service agent, you mark such cases and ensure reports are generated to help you act over them. Let me show you a simple way to do that.

Formula for your success... (Formula Field)

A simple image formula field will do the trick for us! We will use the image formula field to flag cases that have been dormant for a long time (i.e.no comments have been posted for a while). However, as a prerequisite for this, you need to have a Last_Comment_c date field. So, the formula that I used was: 



Voila! It’s done! Now every time you have a case that you have neglected for too long, you will get a red or a yellow flag (depending on your formula) as shown below:


Report: Editing records from within a Salesforce Report

You have used a Salesforce report for not only analyzing and viewing a plethora of information but also for showing up details of columns, filter criteria, date range, etc. What if I tell you that you can not only view all the information, but also edit several records at a go from within the report?

“You’re kidding me!” I already hear some of you say. Hold on! Let me show it to you


Eureka!!!.....Just an Edit!

I am going to add an Edit link right within the report to do this. ‘How?’ you ask me. Here’s how.

I will first create a text formula field. The formula I will need to use is simple enough.


where Object key prefix can be 00Q for Lead, 001 for Account, 003 for Contact, 006 for Opportunity and so on!

Once created, you do not need to display this field on the page layout. However, you will need to display it on the Report layout as shown in the figure below.


So if you want this action link for the Opportunity object, your formula needs to be:


Additional Tip:
You can also use this formula link in List Views

I hope these tricks help you perform simple yet effective magic with Salesforce, just as they help me in my daily tasks. I will be back soon with more tricks up my sleeve!



Written by Vimal Desai, Project Manager at Eternus Solutions


Read More »

Wednesday 11 February 2015

How MSMQ saved my day (and my application too!)

Have you ever tried opening twenty applications on a 1 GB RAM machine? Or tried transferring five blue ray movies in five different windows on that same machine? “Why would you do that, that’s gonna kill your machine!” I can hear some of you saying. I did something similar a couple of days back when I had to send an email to 5000 people. Now I know what you are thinking. Sending mails ain’t rocket science! I agree. But sending it to 5000 people would’ve made my web application unresponsive and I simply could not afford that. I needed a workaround, and that’s when I instantly thought of MSMQ!

MSMQ: My Saviour (Microsoft) Message Queue

Microsoft Messaging Queue (MSMQ) is a message storage area which can be used by one or more than one applications to store and retrieve messages. I used MSMQ to store all the emails on a button click and then wrote a windows service to send the mails to all my recipients. Sending these records to MSMQ queue was not a time consuming job, so it was done rather quickly and the application was free to service the next user request.

Basically, my Web Application would now send the messages to the queue and then be free to execute the next request made by the user. A Windows service continuously running in the background would send the emails (and do the time-consuming job, without killing my application!). 


First things first: Installing MSMQ

Before I show you how to make MSMQ work, let me first show you how to install it properly.

Step 1:
Go to Control Panel –> Programs –> Turn Windows Features On or off

Step 2:
Select Microsoft Messaging Queue (MSMQ) Server

This will install MSMQ on your machine.

Creating a Queue

In order to create a new queue, simply right click on My Computer and select Manage, as I have shown below:

You can also create a queue through programing using a System.Messaging namespace. If you are working on Visual Studio for Web, you might need to add this DLL from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1. 

For creating a new queue, you will need to specify a queue name in a specific format. The queue name needs to start with a “.” and should have a “$” after private, as shown below in the example. 


e.g. “.\\Private$\\Queue1”

The above code will create a new queue if it does not already exist.

The battle begins: Inserting Messages in the Queue

Now came the crunch part: to insert messages in the queue I just created. I used the following code snippet to insert the messages into my newly created queue:

The above code will give you an exception if queuing is not enabled. I also created a class EmailMessagedata where I set all the properties like emailID, subject, body etc. You can use the following code snippet for the same:


Providing the finishing touches: Retrieving Messages from the Queue

Now all I had to do was to retrieve these inserted messages and send mails or perform the required operation. I retrieved all the messages from Queue1 and saved them in an array, and then deleted all the messages in Queue1 using purge().

You need to add a reference to the Web Application’s DLL using which you can insert the message in the queue to get the message content in the format specified in your EmailMessagedata class.

My takeaway

Using this approach, I was able to save a lot of time as all my emails were stored in the MSMQ. I did not have to wait while my emails were being sent; I was able to continue using the application while the windows service was sending the emails in the background. All this while, my application remained responsive. If you need to execute time consuming tasks, I would recommend you use MSMQ. Just as it saved my day, I am sure it will save yours too.



Written by Manish Patil, Dotnet Developer at Eternus Solutions
Read More »