Showing posts with label Salesforce. Show all posts
Showing posts with label Salesforce. Show all posts

Monday, 7 October 2013

Quick Fix :- How to build the URL to launch an Email template via Standard Screening



Case Study:

How to Create an email template that will Auto Fill the account, and primary contact when selected from the Send Email from the Opportunity Activity History panel.

Clicking on Send Email from there gives a blank window to send email from - How to fill them with information from the record which they are coming from

Solution :-

One click java-script to Send an email using standard emailing screen. See below :-

location.replace('/email/author/emailauthor.jsp?retURL=/{!Account.Id}&p24=<To Email Address>&template_id=<email template id>&p3_lkid={!Account.Id}&p3={!Account.Name}&p26=<from email address>&p5=&save=0');

Let us quickly analyze the URL Parameters :-

p2_lkid = it is "Email TO" Field Code , associated only with Contact ID of Contact Standard Object, populares the Contact in To Field of Email.

rtype = record type 001 means Account and so on

p3_lkid = whatId ( hidden lookup field) it is must if the merge fields are there in template

p24 = additional email to be added as addional

retURL = returning URL

p5 = stops adding more BCC

p26 = to change the domain from which you are sending

template_id - Email Template Id, It can have merge fields.

save = 0, means send the email automatically and return to retURL ,( leave it if you just need to see the screen with populated fields)

The aforementioned fields are standard fields provided from Salesforce side. These arent customizable but you can specify values for this as per your need and requirements. You can give merge fields values over there and that may help.

Thursday, 8 August 2013

Batch Apex & CSV Parsing - I am Lovin'it !!


Situation :

I have a CSV File with 3 Fields Lead ID , Yes|No Field and Operator Name.
Without Using Data Loader I need my Data Entry Team to Upload this File  and Leads get updates with these values in the respective fields.



Solution :

Perhaps , Data Loader is the Mirror Cracking Solution. But you cannot get all the happiness at once.

Making the Data Entry team familiar with Data Loader and expecting that they will do correct is like expecting a lion not to eat you all because you are a Vegetarian.

So , Clear Cut My Process was turned up to Batch Apex CSV Parsing . Yes ! You Heard It Correct Batch Apex CSV Parsing .

So , I went to my Manager with this serving on Plate...

I will create a Visualforce Page with a Browse Button.
When a CSV File with Correct Format is Uploaded from there.It will call an controller which will call the Batch Process . The Batch will call a class which will insert records from the values which it gets from another class. Make Sense ?

His words "Sounds Delicious !! "

So , I started upon it .. Here are the ingredients

1.  Page -- BatchUpdateLeads

/* This will be the Visualforce Page with the Browse Button. /*

2. ctrlUpdateallrecFromCSV

/* This will be the Extension which will be called from the Page. /*

3. BatchProcessor

/* Called from the Extension, This is the Actual Batch Process. /*

4. BatchSObjectFeeder

/* This will be an Input for the Batch Apex in its Start Method. /*

5. ctrlAdddataFromCSV

/* This will be the called from the Batch Apex. "InsertValues"  Method will be called. Also , This is the class responsible for Saving the Records in Salesforce. /*
6. clsAdddataFromCSV

/* This is the Class called from ctrlAdddataFromCSV , The main process of this is to parse the excel sheet  . /*



Get the Code from Here ..
Disclaimer : This is a chain of classes as I respect OOP Concepts.


Hope it works well for you all !

Happy Batch Update !! :-)