Monday, January 30, 2017

Email-to-Case Setup in Salesforce

Salesforce can automatically create a case when an email is sent to one of your company's email addresses, such as support@company.com. This Email-to-Case functionality auto-populates case fields from the content of each email. For example, an email subject heading becomes a case subject. Your organization can set up Email-to-Case or On-Demand Email-to-Case to efficiently resolve and correspond with customer inquiries via email. Salesforce allows you to choose one of two Email-to-Case options:

Email-to-Case
Email-to-Case requires downloading the Email-to-Case agent from wiki.developerforce.com/index.php/Email_To_Case and installing the agent behind your network's firewall.
Use Email-to-Case if you have a requirement to keep all email traffic within your firewall, and you want to accept email attachments larger than 25 MB from customers.

On-Demand Email-to-Case
On-Demand Email-to-Case uses Apex email services to convert email to cases, without you having to download and install an agent behind your network's firewall.
Use On-Demand Email-to-Case if you are not concerned about keeping email traffic within your firewall and you do not need to accept attachments larger than 25 MB from customers.


Setting Up On-Demand Email-to-Case
1. Click Setup ➤ Customize ➤ Cases ➤Email-to-Case ➤ Edit ➤ Check Enable Email-to-Case ➤ Check Enable On-Demand Service ➤ Click Save.


2. From the Routing Addresses related list, click the ‘New’ button to create a new Routing Address. 

Enter Routing Name (some name),Email Address (Customer complaints email address),If you want to create a Task When case comes then Select Create Task from Email,Task Status.Select Case Priority and Case Origin,Click  Save.

   

 3. Open Your Email Inbox in my case it is (Support@company.com) and Click on verification link to verify the email.

4. After Verification it will take you to salesforce Home page,Open Email-to-Case from Setup,You will see Some Information in Routing Addresses related list. 

5. Open Your Email ( In my Case it is GMAIL),Click on Settings,Click on Forwarding and POP/IMAP Tab.


6.Click on Add a forwarding address Copy and paste the Email Service Address from Routing Addresses related list.

Thats all.

Now send an email to Email Address ( In my case it is Support@company.com ).

See that ,The case is automatically created in salesforce.





Wednesday, January 25, 2017

                                                                          Field Analyzer

Enhancements done by Me.


1.No Need To add Remotesite Settings Manually.


2.Added a Link in the Page If we click on it it will Redirect to the Details page of the Analysis.




3.Added User Input Validation .(While adding new Org If user try to Save Org details with Empty Fields Validation will thrown).




4.Added Org Details Validation .(While adding New Org If User Enter Wrong Information and try to save Validation will thrown).




Tuesday, January 24, 2017

RelationShip Between Opportunity ,OpportunityLineItem ,Product, PriceBook And PriceBookEntry.




OpportunityLineItem is the Junction Object Between Opportunity and PriceBookEntry.

PriceBookEntry is the Junction Object Between Pricebook and Product.



Wednesday, January 18, 2017

Inline VisualForce Page to Send Notes & Attachment to the Owner of the Account from Account Detail Page.





Page:

<apex:page standardController="Account" extensions="NotestAttsRelatedListController">
<apex:form >
<apex:pageBlock >
     <apex:pageblock title="Attachments">
            <apex:pageblockTable value="{!atts}" var="a">
            <apex:column headerValue="Actions">
                <apex:outputLink value="{!URLFOR($Action.Attachment.Download, a.Id)}" target="_blank">View</apex:outputLink>
            </apex:column>
            <apex:column value="{!a.Name}" headerValue="Title"/>
            <apex:column value="{!a.BodyLength }" headerValue="Size"/>
    <!--        <apex:column value="{!a.Parent.Type}" headerValue="Object Name"/>
            <apex:column value="{!a.Parent.Name}" headerValue="Record Name" />   -->
            <apex:column value="{!a.Owner.Name}" headerValue="Owner Name"/>
            <apex:column value="{!a.LastModifiedDate}"/>
            <apex:column headerValue="Send As Email">
                <apex:commandLink value="Send Attachment" action="{!SendAttachment}">
                    <apex:param name="attId" value="{!a.Id}" assignTo="{!aId}" />
                </apex:commandlink>
            </apex:column>
            </apex:pageblockTable>
  </apex:pageblock>
</apex:pageBlock>
</apex:form>

</apex:page>

Controller:

public class NotestAttsRelatedListController {

    public list<Attachment> atts {get;set;}
    public String aid {get; set;}

    public NotestAttsRelatedListController(ApexPages.StandardController controller) {
     
         atts = [Select a.Id,a.ContentType,a.ParentId,a.Parent.Type,a.Parent.Name,a.OwnerId,a.Owner.Name, a.Name, a.LastModifiedDate, a.BodyLength From Attachment a
               where a.ParentId=:ApexPages.currentPage().getParameters().get('id')];
    }
 
    Public pagereference SendAttachment(){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        Account r = [select Owner.Email,Name from Account where Id= :ApexPages.currentPage().getParameters().get('id')];
        String[] toAddresses = new String[] {r.Owner.Email};  
        mail.setToAddresses(toAddresses);
        mail.setSenderDisplayName('Name');
        mail.setSubject('Attachment');
        mail.setBccSender(false);
        mail.setUseSignature(true);
        mail.setPlainTextBody('This is test email body. This mail is being sent from apex code');
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for (Attachment a : [select Name, Body, BodyLength from Attachment where Id= :aid]){
            Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
            efa.setFileName(a.Name);
            efa.setBody(a.Body);
            fileAttachments.add(efa);
        }
        mail.setFileAttachments(fileAttachments);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        return null;
    }

}

Note: After Creation of VF page add it to Account page layout Otherwise it will show Visualforce Error.