Find your content:

Search form

You are here

Can an attachment be sent from a web2lead form into Salesforce lead?

 
Share

Can we have an attachment on Leads?

Can the attachment be sent over from a web to lead form?


Attribution to: Prady

Possible Suggestion/Solution #1

Solution i provided for web2lead with attachments Most of the Situations companies Web 2 Lead form will be a contact us page on companies web site or any specific Landing Pages, Request for information forms or Trial Download forms. in my case customer is using the form for accepting Job Application forms which should support candidates resume as Attachment .

Add one more form with file upload fields and button , remove the submit button on your Salesforce lead forms. On button click call a Java Script Function

  1. Generate a Attachment Key

  2. Submit File Upload Form using AJAX along with the uploaded files submit the Generated Attachment key also to the Action Page

  3. Action page should Validate the File Type File Size and Attachment Key

  4. On Successful Validation Send the attachment as email to Salesforce Email Service and return Success Message

On receipt of Success Message Submit the Salesforce form with the generated attachment key as value on a Custom Field Created on Salesforce Lead Object.

Email sent to Salesforce email service will trigger a Apex Class which will process the attachments if it finds the lead with the matching attachment key then Link the attachment to the lead if lead creation is delayed store the Key and attachments to a custom object. Add a Trigger on the lead object which should match the Attachment record on the attachment object based on the Attachment Key and link it to the lead record and delete the Attachment record created on the custom object

http://blog.soquelllc.com/?p=1


Attribution to: SOQUEL

Possible Suggestion/Solution #2

You can have attachments added to Leads (you can enable that on the setup of the Leads page layout object).

enter image description here

As for adding attachments from the web form itself - I am not aware of a standard setting, but a short google search, brought 2 options

http://boards.developerforce.com/t5/General-Development/web-to-lead-form-with-attachment/td-p/336137


Attribution to: Saariko

Possible Suggestion/Solution #3

This is not possible i feel out of box.

You can definately use sites to do this .

http://wiki.developerforce.com/page/Web2Lead_with_Force.com_Sites

Here is the document from wiki.

You can use input file tag in your Visualforce page to upload the attachment into salesforce.

<apex:form >
                    <apex:pageBlock >
                        <apex:pageBlockSection >
                            <apex:inputFile styleClass="btnSendNow" value="{!newAttachment.body}" filename="{!newAttachment.name}"/>
                            <apex:commandButton styleClass="button btnSendNow" value="Upload" action="{!Upload}"/>
                        </apex:pageBlockSection>
                    </apex:pageBlock>
                </apex:form>

public Attachment newAttachment {
    get {
        if (newAttachment == null) newAttachment = new Attachment();
        return newAttachment;
    }

    set;
}

          public PageReference upload() {
    String caseId=ApexPages.currentPage().getParameters().get('id'); 
    system.debug('caseId in upload:'+caseId);
    newAttachment.parentid = caseId;
    try{
        insert newAttachment; 
    }catch(Exception e){
        system.debug(e.getMessage());               
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error in file upload:'+e.getMessage()));
    }     
    system.debug('New attachment uploaded');
    newAttachment.Body=null;

    PageReference thisPage=ApexPages.currentPage();
    thisPage.getParameters().put('id',caseId);
    return thisPage;
 }

Attribution to: Mohith Shrivastava

Possible Suggestion/Solution #4

Well I achieved this using a different approch other that Web To Lead as I wanted to use the attachment feature.

  1. Enable Email Service in Salesforce by navigating Setup > Develop > Email Service. More details here.Create an Email Service that will accept email from a particular email id. (Email service will give u an recipeint email ID)

  2. Create An Inbound Email handler class that will process the email body and attachment.

  3. Parse the Email body,populate the appropriate fields and insert it.

  4. Use the atatchment ,add it to the created Lead . Voila its done.

  5. Now in your normal site, create a normal form , with textfields and attachment field. On click on Save/Submit button run the code to sent an email to the id of emailservice of salesforce. (Google for Email sending code in the language used by your site, you will easily find it) . Put the data you captured from form in the JSON as email body(Json is easy to read in Apex or in any other language).

Here is the class sampleof how I did this.

global class LeadWithAttachmentEmailHandler implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
    Lead l;
    Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();

    try {
        l = new Lead();
        String emailBody = email.plainTextbody;
        Map < String, String > bodyDataKeyValuePair = (Map < String, String > ) Json.deserializeUntyped(emailBody);
        //Populate the lead fields using this way   
        l.Email = bodyDataKeyValuePair.get('Email');
        insert l;
        //to save attachment to the newly inserted lead. Attachment size currently via inbound mail is restricted to 5MB
        for (Messaging.Inboundemail.TextAttachment tAttachment: email.textAttachments) {
            Attachment attachment = new Attachment();
            attachment.Name = tAttachment.fileName;
            attachment.Body = Blob.valueOf(tAttachment.body);
            attachment.ParentId = l.Id;
            insert attachment;
        }

        result.success = true;
    } catch (Exception e) {
        result.success = false;
        result.message = 'Failed to insert Lead.' + e.getMessage();
    }
    return result;
}

}


Attribution to: Pranay Jaiswal
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/3842

My Block Status

My Block Content