Web to Case is available out-of-the box under Setup -> Customize -> Self Service -> Web to Case. This article is only intended to give you an understanding of Google forms and workflow rules on the "Email Message" object as well as one way of sending information to Salesforce from the google platform.
STEP 1:
You should be having a google Account. Click on the "Documents" link when you are in gmail. You can find it at the top bar as shown below.
STEP 2:
Create a new form as shown below.
STEP 3:
A sample form creation screen is shown below
Click the "Save" button to save the form.
STEP 4:
Now go back to your "Documents" tab as shown in STEP 1. You will now see a document named "Web to Case Form" and clicking on it would open up a spreadsheet as shown below.
Replace the value "XYZ" in the email variable with the "Email Service Address" that you noted down in STEP 5.
Go to "File" menu and select "Save". Give in some name and save the file.
Now, go to "Resources" menu and select "Current Script's Trigger" as shown below and save the changes.
STEP 1:
You should be having a google Account. Click on the "Documents" link when you are in gmail. You can find it at the top bar as shown below.
STEP 2:
Create a new form as shown below.
A sample form creation screen is shown below
Click the "Save" button to save the form.
STEP 4:
Now go back to your "Documents" tab as shown in STEP 1. You will now see a document named "Web to Case Form" and clicking on it would open up a spreadsheet as shown below.
GETTING TO THE SALESFORCE PART:
STEP 5:
Create a new Email to Case address as shown below and make a note of the Email Service Address.
STEP 6:
We will now create a workflow rule to update the CASE field PRIORITY with the value entered in the google form. Go ahead and create a workflow rule on the "Email Message" object.
NOTE: The entry criteria will be Email Message : Text Body contains "What is the severity :: High"
STEP 7:
Let's get back to google now. Open the document as shown in STEP 4.
Click on the "Tools" menu and select "Script Editor". Paste the following code in the editor window.
function sendFormByEmail(e)
{
// Remember to replace XYZ with your own email address
var email = "XYZ";
// Optional but change the following variable
// to have a custom subject for Google Docs emails
var subject = "Google Docs Form Submitted";
// The variable e holds all the form values in an array.
// Loop through the array and append values to the body.
var message = "";
for(var field in e.namedValues) {
message += field + ' :: '
+ e.namedValues[field].toString() + "\n\n";
}
MailApp.sendEmail(email, subject, message);
}
Replace the value "XYZ" in the email variable with the "Email Service Address" that you noted down in STEP 5.
Go to "File" menu and select "Save". Give in some name and save the file.
Now, go to "Resources" menu and select "Current Script's Trigger" as shown below and save the changes.
STEP 8:
Now, go to your Google form. Select the Priority as "High" and submit the form. Your Case is created in Salesforce and the Priority is updated as "High".
This article covers the SFDC table which stores Chatter Follower information (ie It stores which user follows which Account, Contact , or any record or User).
The table is
EntitySubscription:
The fields in this table are
ParentId: The ID of the Account, Contact or any record or User.
SubscriberId: The ID of the user who follows the record denoted in the Parent ID.
Querying this object would give you Follower Information
For Example:
To Add followers automatically using Apex, you could insert records into this object. And to Un-follow just delete the relevant records.
The table is
EntitySubscription:
The fields in this table are
ParentId: The ID of the Account, Contact or any record or User.
SubscriberId: The ID of the user who follows the record denoted in the Parent ID.
Querying this object would give you Follower Information
For Example:
List<EntitySubscription> myaccsubscribers = [Select ParentId,SubscriberId
from EntitySubscription where ParentId = '500Q11100046Vt3'];
To Add followers automatically using Apex, you could insert records into this object. And to Un-follow just delete the relevant records.
EntitySubscription newfollower = new EntitySubscription();
newfollower.ParentId = 'insert id here';
newfollower.SubscriberId = 'insert the user id here';
insert newfollower;
A few weeks back i was looking around the appexchange to find some cool chatter apps, and i found these two which were awesome.
ChatterBot Auto response:
Install:
This app acts as a bot and responds to chatter posts based upon keyword match. It also has other cool features like automatic case creation from a chatter post. Moreover, the code is written generically. So, it's pretty easy to extend and adapt to specific needs.
Auto Response:
I just set up an auto response rule to point users to a help document link when their chatter post contains "chatter email settings". Here is a snapshot of the rule
And here is a screencap after the BOT in work.
Automatic Case Creation from chatter posts:
If your chatter posts contains the keyword {!case}, the BOT creates a case and gives the case number as a comment to your post. Here's one in action.
Note: I created a user called ChatterBot, and started the Bot jobs as this user. Also, the BOT's work on scheduled intervals (every 1 hour i guess), you can also run it manually on the click of a button.
Chatter Swarm 3:
Install
This app allows setting up rules for automatically following Accounts, Cases Opportunities etc and custom objects too.
Here's a new swarm rule which says that when a Lead is updated or created with a status of "Working - Contacted", then the Lead needs to be automatically followed by two users.
The Swarm in action.
Note that you could set up rules for Lead, Opportunity, Cases and chatter posts.
ChatterBot Auto response:
Install:
This app acts as a bot and responds to chatter posts based upon keyword match. It also has other cool features like automatic case creation from a chatter post. Moreover, the code is written generically. So, it's pretty easy to extend and adapt to specific needs.
Auto Response:
I just set up an auto response rule to point users to a help document link when their chatter post contains "chatter email settings". Here is a snapshot of the rule
And here is a screencap after the BOT in work.
Automatic Case Creation from chatter posts:
If your chatter posts contains the keyword {!case}, the BOT creates a case and gives the case number as a comment to your post. Here's one in action.
Note: I created a user called ChatterBot, and started the Bot jobs as this user. Also, the BOT's work on scheduled intervals (every 1 hour i guess), you can also run it manually on the click of a button.
Chatter Swarm 3:
Install
This app allows setting up rules for automatically following Accounts, Cases Opportunities etc and custom objects too.
Here's a new swarm rule which says that when a Lead is updated or created with a status of "Working - Contacted", then the Lead needs to be automatically followed by two users.
The Swarm in action.
Note that you could set up rules for Lead, Opportunity, Cases and chatter posts.
Whenever a user creates a new Account, Contact, Opportunity or any custom object record it is sometimes required to automatically populate certain fields with values.
You could do this by setting the "default" value on a text field. However, there are number of restrictions. One workaround would be to use Workflow rules for field updates, but remember workflow rules are fired only after you hit the "Save" button
Let's say that you would want the default value of the "Billing Country" field on Account to be set to "India". The video below shows how to do this by passing values through the URL.
P.S: This is not a best practice, but just in case it might help in some situations. You could override the "New" button and pass parameters through the URL.
You could do this by setting the "default" value on a text field. However, there are number of restrictions. One workaround would be to use Workflow rules for field updates, but remember workflow rules are fired only after you hit the "Save" button
Let's say that you would want the default value of the "Billing Country" field on Account to be set to "India". The video below shows how to do this by passing values through the URL.
P.S: This is not a best practice, but just in case it might help in some situations. You could override the "New" button and pass parameters through the URL.
UPDATE: With the Spring 2013 release, the steps described below have become bit more complicated.
The Show/Hide Chatter toggle sometimes might make the page look too long. When you have a lot of chatter going on, the page becomes really big and your detail page or the home page goes way down under.
Even when you can't control the size of your chatter frame, hiding it by default would be ideal i think. And so, this bit of code. Add this code to a home page component, to a visualforce page, or add it to a visualforce page and embed it within standard page layouts.
Use this, when you have chatter inside a visualforce page. Make sure that this code gets called after the entire page has loaded. Pasting this code towards the end of the visualforce page should be fine. In case it doesn't work, put the code inside a function and call the function after page load using "window.onload = functionname();"
var e = document.getElementById("showFeedLink");
if(e.style.display == "none")
chatter.getFeed().toggle('{"subjectId":"a4MV00000032ixk","feedType":"ENTITY"}', false);
The portion marked in RED denotes the record ID.Use this, when you want to hide chatter in the home page. Create a new Home Page Component and select "HTML Area" and then check the "Show HTML" checkbox and paste this code.
function hidechatter()
{
var e = document.getElementById("showFeedLink");
if(e.style.display == "none")
chatter.getFeed().toggle('{"subjectId":"a4MV00000032ixk","feedType":"NEWS"}', false);
}
window.setTimeout("hidechatter()", 2000);
}
The portion marked in RED denotes the USER ID.
The below diagram is what we are going to build. This hierarchy is based upon the manager field in the user object. The below example is NOT based upon the role hierarchy. Anyhow, you can modify the code below to fit the role hierarchy.
Visualforce Page:
Visualforce Page:
<apex:page controller="orgchart" showHeader="false">
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['orgchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addColumn('string', 'ToolTip');
data.addRows([
{!userdata}
]);
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
chart.draw(data, {allowHtml:true});
}
</script>
</head>
<body>
<div id='chart_div' style="font-size:18px;"></div>
</body>
</html></apex:page>
Apex Class
public class orgchart {
Public String getuserdata()
{
List<User> allusers = [Select Name,Manager.Name from User where IsActive = TRUE and ManagerId != NULL];
String datastr = '';
for (integer i=0;i<allusers.size();i++)
{
datastr = datastr + '[\'';
datastr += allusers[i].Name;
datastr+= '\',\'';
datastr+= allusers[i].Manager.Name;
datastr+='\',\'\'],';
}
datastr = datastr + '';
return datastr;
}
}
I wanted to run a report to fetch all users in our salesforce org and then group them by their License type.
Problem with Standard Report: You can use the Standard report on the User object and use the "UserType" field. But the problem is that this field is not very specific. For instance, this field has a type name "Salesforce" for both the "Salesforce" license type and the "Salesforce Platform" license type.
To get a more in-depth report, i used the Apex Data Loader and exported data from a few objects to arrive at the final report.
Objects to consider:
Profile:
API doc http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_profile.htm
Field: UserLicenseId
User:
API doc:http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_user.htm
Field: ProfileId
UserLicense:
API doc: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_userlicense.htm
Field: LicenseDefinitionKey
Open Apex Data Loader. Select "Export" and select the object "User" and paste the following query.
Problem with Standard Report: You can use the Standard report on the User object and use the "UserType" field. But the problem is that this field is not very specific. For instance, this field has a type name "Salesforce" for both the "Salesforce" license type and the "Salesforce Platform" license type.
To get a more in-depth report, i used the Apex Data Loader and exported data from a few objects to arrive at the final report.
Objects to consider:
Profile:
API doc http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_profile.htm
Field: UserLicenseId
User:
API doc:http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_user.htm
Field: ProfileId
UserLicense:
API doc: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_userlicense.htm
Field: LicenseDefinitionKey
Open Apex Data Loader. Select "Export" and select the object "User" and paste the following query.
Select Id,Name,Profile.Name,Role.Name,Profile.UserLicenseId from User
Open Apex Data Loader. Select "Export" and select the checkbox "Show all Salesforce objects". Now, select the object "UserLicense" and paste the following query.
Select LicenseDefinitionKey,Name from UserLicense
Now, do a "Excel Vlookup" between the Profile.UserLiceseId column in the first csv file and the "LicenseDefinitionKey" in the second csv file. The Name column in the second csv file denotes the actual salesforce license Name.
If you are not familiar with Vlookup, then watch this video
Note:I tried this only with the LEN function and i hope it works with other formula functions as well.
My requirement:
I wanted to calculate the length of a couple of fields of data type Text Area, and put the number into a new field.
As usual, i created a formula field and used the LEN function. When i tried to INSERT my Long Text Area fields, they were not available for selection. I later found out that you cannot use Long Text Area fields in formulas as of now. Hope that it becomes available soon, until then here is a workaround.
Let's say that i have an object named "MyCustomObject__c". I want to calculate the sum of the length of the Long Text Area fields Field1__c, Field2__c, Field3__c and put the value into SumofLenght__c
STEP 1: Create a new field on the object MyCustomObject__c named "SumofLength__c" of datatype "Number".
STEP 2: Create a new Workflow rule on the object "MyCustomObject__c"
Evaluation Criteria: Every time a record is created or edited
Rule Criteria: MyCustomOject Name: NOT equal to NULL
STEP 3:
Create a Workflow Field Update as below
My requirement:
I wanted to calculate the length of a couple of fields of data type Text Area, and put the number into a new field.
As usual, i created a formula field and used the LEN function. When i tried to INSERT my Long Text Area fields, they were not available for selection. I later found out that you cannot use Long Text Area fields in formulas as of now. Hope that it becomes available soon, until then here is a workaround.
Let's say that i have an object named "MyCustomObject__c". I want to calculate the sum of the length of the Long Text Area fields Field1__c, Field2__c, Field3__c and put the value into SumofLenght__c
STEP 1: Create a new field on the object MyCustomObject__c named "SumofLength__c" of datatype "Number".
STEP 2: Create a new Workflow rule on the object "MyCustomObject__c"
Evaluation Criteria: Every time a record is created or edited
Rule Criteria: MyCustomOject Name: NOT equal to NULL
STEP 3:
Create a Workflow Field Update as below
So, i did a data export from salesforce.com and wanted to get the month from a date time field...
The general format of DateTime fields is like this 2012-01-15T18:34:00.000Z
If suppose you have this in column D in excel, just type in the following formula in an adjacent column
Say you do it in E1
=SUBSTITUTE(SUBSTITUTE(D1,”T”,” “),”.000Z”,”")
This eliminates the time part and you just get the date value....
Now, simply double-click on the bottom edge of E1 and the formula would be applied to the entire column E.
Now, E might still represent some number... Select the entire E column, right click and select "Format Cells" and select the category as "Date"...
To fetch the Day, Month and Year from column E, use the formulas = DAY(E1), =MONTH(E1), =YEAR(E1) ...
The general format of DateTime fields is like this 2012-01-15T18:34:00.000Z
If suppose you have this in column D in excel, just type in the following formula in an adjacent column
Say you do it in E1
=SUBSTITUTE(SUBSTITUTE(D1,”T”,” “),”.000Z”,”")
This eliminates the time part and you just get the date value....
Now, simply double-click on the bottom edge of E1 and the formula would be applied to the entire column E.
Now, E might still represent some number... Select the entire E column, right click and select "Format Cells" and select the category as "Date"...
To fetch the Day, Month and Year from column E, use the formulas = DAY(E1), =MONTH(E1), =YEAR(E1) ...
VF dashboards
Advanced reporting and Dashboards in Salesforce: Google Visualization with Visualforce
3:35 PMIf you haven't yet tried your hand with Google Visualization API's this is the best time to start...
Here is the link to the documentation to get started .. http://code.google.com/apis/chart/interactive/docs/reference.html
A very cool feature of this is you could generate charts just by passing parameters in the URL.
It's as simple as this, click the link https://chart.googleapis.com/chart?cht=p3&chs=450x100&chd=t:30,20,20,15,15&chl=Open|In Progress|On Hold|Pending Confirmation|Closed
As you can see, the values in PINK color are the actual segments of the chart. You may split the entire 100% as per your req, and the text in GREEN is the value for each of the segments.
How can i use this?
Well, you could just embed this into a Standard Page Layout using just a formula field. So, you get a real time snapshot right inside your detail page.
Also, you could do some complex calculations in your apex class and pass the results of the calculation to the URL as parameters and you have a nice little graph.
Refer to the documentation for more samples and chart types. http://code.google.com/apis/chart/interactive/docs/reference.html
Here is the link to the documentation to get started .. http://code.google.com/apis/chart/interactive/docs/reference.html
A very cool feature of this is you could generate charts just by passing parameters in the URL.
It's as simple as this, click the link https://chart.googleapis.com/chart?cht=p3&chs=450x100&chd=t:30,20,20,15,15&chl=Open|In Progress|On Hold|Pending Confirmation|Closed
As you can see, the values in PINK color are the actual segments of the chart. You may split the entire 100% as per your req, and the text in GREEN is the value for each of the segments.
How can i use this?
Well, you could just embed this into a Standard Page Layout using just a formula field. So, you get a real time snapshot right inside your detail page.
Also, you could do some complex calculations in your apex class and pass the results of the calculation to the URL as parameters and you have a nice little graph.
Refer to the documentation for more samples and chart types. http://code.google.com/apis/chart/interactive/docs/reference.html
Update: There's a simple way as pointed out by Scott Hemmeter in his comment below. Just use the sort() method and the first element in the list is the MAX or MIN based upon your sort (DESC or ASC). Thanks, Scott
This is just a way that i followed, not sure if LIST's have a pre-defined function to find out the maximum... If you do find a easier way, share it in the comments box below.
Here, "samplevalues" is a LIST of Decimal's
This is just a way that i followed, not sure if LIST's have a pre-defined function to find out the maximum... If you do find a easier way, share it in the comments box below.
Here, "samplevalues" is a LIST of Decimal's
List<Decimal> samplevalues = new List<Decimal>();
samplevalues.add(55.0);
samplevalues.add(75.5);
samplevalues.add(99.3);
Decimal maxvalue = samplevalues[0];
For (integer i =0;i<samplevalues.size();i++)
{
if( samplevalues[i] > maxvalue)
maxvalue = samplevalues[i];
}
system.debug('the max value is'+maxvalue);
Many thanks to Mr.Ranjeet Singh for submitting this article. This article is a sample code which lets you upload contacts from a Visualforce Page using a CSV file...
Click here if you too would like to submit an article for this blog
Step 1:
Click here if you too would like to submit an article for this blog
Step 1:
1) Create the Apex Class: UploadRecordUsingCSVContact
public with sharing class UploadRecordUsingCSVContact {
public Blob FileRecords{get;set;}
String[] LineNo=new String[]{};
List<Contact> AllContact;
Public Pagereference UploadFile()
{
String FileData=FileRecords.toString();
LineNo=FileData.split('\n');
Allcontact=new List<Contact>();
for(Integer i=1;i<LineNo.size();i++)
{
Contact con=new Contact();
String[] ActualData=new String[]{};
ActualData=LineNo[i].split(',');
con.FirstName=ActualData[0];
con.LastName=ActualData[1];
con.Email=ActualData[2];
con.Phone=ActualData[3];
Allcontact.add(con);
}
try
{
insert Allcontact;
}
catch(Exception e)
{
}
return Null;
}
Step 2: Create VF Page: UploadRecordUsingCSVContact
<apex:page controller="UploadRecordUsingCSVContact" >
<apex:form >
<apex:sectionHeader title="Upload Contact Records uing CSV File"/>
<apex:pageblock >
<Center>
<apex:inputfile value="{!FileRecords}"></apex:inputfile><apex:commandButton value="Upload File" action="{!UploadFile}"/><br/><br/>
<font color="Red"><b>Note: <a href="{!$Resource.ContactUploadTemplate}" target="__blank">Click Here </a>To download the Format.</b></font>
</Center>
</apex:pageblock>
</apex:form>
</apex:page>
Step 3: Create a CSV File and the file must be in the following mentioned Format:
First Name | Last Name | Phone | |
Ranjeet | Singh | xxxxx@gmail.com | xxxxxxx |