• Bittus
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 21
    Replies
Hi all,

I need to add a custom field of Account object to Standard Task&Event Report type. How can i do this?
Hi All,

I am working on a Test Class and not able to cover the list in private method.

Controller:-
----------------
public class addWholesaleForcastController {
    public string selectedYear{get;set;}
    string recordTypeId = '';
    string retURL = '';
    set<String> setRegion = new set<String>();
    public String dbAction{get;set;}
    public addWholesaleForcastController(ApexPages.StandardController controller) {
        getRegions();
        selectedYear = ApexPages.currentPage().getParameters().get('year');
        retURL = ApexPages.currentPage().getParameters().get('retURL');
        List<RecordType> lstRt = [Select Id from RecordType where sObjectType='SalesForecastData__c'
            and DeveloperName='Monthwhl'];
        if(lstRt.size()>0){
            recordTypeId = lstRt[0].Id;
        }
        getWholesaleData();
    }
    public PageReference cancel(){
        PageReference P = new PageReference(retURL);
        return P;
    }
    public PageReference save(){
        try{
            List<SalesForecastData__c> lstData = new List<SalesForecastData__c>();
            if(lstWholesale.size()>0){
                for(Wholesale data:lstWholesale){
                    lstdata.add(data.data);
                }
            }
            if(lstdata.size()>0) upsert lstdata;
            //////////////
            PageReference P = new PageReference(retURL);
            return P;
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,ex.getMessage()));
            return null;
        }
    }
    public List<Wholesale> lstWholesale{get;set;}
    void getWholesaleData(){
        lstWholesale = new List<Wholesale>();
        if(common.NVL(selectedYear) != ''){
            List<SalesForecastData__c> lstData = [Select Id, Name, Region__c, Region_Text__c,
                Jan__c, Feb__c, Mar__c, Apr__c, May__c, Jun__c, Jul__c, Aug__c, Sep__c,
                Oct__c, Nov__c, Dec__c, Year__c
                from SalesForecastData__c Where Year__c =:selectedYear and RecordtypeId=:recordTypeId];
            if(lstData.size()>0){
                dbAction = 'Update';
                for(SalesForecastData__c data:lstData){
                    lstWholesale.add(new Wholesale(data));
                }
            }
            else{
                dbAction = 'Add';
                if(setRegion.size()>0){
                    for(String rgn:setRegion){
                        SalesForecastData__c data = new SalesForecastData__c();
                        data.Year__c = selectedYear;
                        data.Region__c = rgn;
                        data.RecordtypeId=recordTypeId;
                        lstWholesale.add(new Wholesale(data));
                    }
                }
            }
        }
    }
    void getRegions(){
        setRegion.add('01');
        setRegion.add('02');
        setRegion.add('03');
        setRegion.add('04');
        setRegion.add('05');
        setRegion.add('06');
        setRegion.add('07');
        setRegion.add('08');
        setRegion.add('09');
        setRegion.add('10');
        setRegion.add('11');
        setRegion.add('12');
        setRegion.add('13');
        setRegion.add('14');
        setRegion.add('15');
        setRegion.add('16');
        setRegion.add('Cent');
        setRegion.add('East');
        setRegion.add('None');
        setRegion.add('S&G');
        setRegion.add('West');
    }
    class Wholesale{
        public SalesForecastData__c data{get;set;}
        public Wholesale(SalesForecastData__c data){
            this.data = data;
        }
    }
}

Test Class:-
------------------------
@isTest
public class Test_WholesaleForcast {
static testMethod void Test_WholesaleForcast2(){
        List<RecordType> lstRT2 = [Select Id from RecordType Where DeveloperName='Monthwhl' and sObjectType='SalesForecastData__c'];
        String recordtypeId = 'Monthwhl';
        SalesForecastData__c Sales2 = new SalesForecastData__c(Year__c = '2014');
               insert sales2;
        Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(sales2);
        addWholesaleForcastController  addwhlsale = new addWholesaleForcastController (sc);
        addwhlsale.save();
        addwhlsale.dbAction = 'abc';
        addwhlsale.selectedYear = '2014';
        Test.stopTest();
    }

}
Hi ,
I am trying to send a meeting invitation from salesforce to outlook or Gmail with meeting date and time. I have a code to do this, but it is hardcoded. I need to send the meeting invitation with date and time as mentioned by the user.

Here is the code:-
Vf page:-

<apex:page controller="SendEmail">
    <apex:form >
        <apex:pageblock >
            <apex:pageblocksection columns="2">
                <apex:outputText value="Email"/><br/>
                <apex:inputText value="{!sendTo}"/><br/>
                <apex:outputText value="Subject"/><br/>
                <apex:inputText value="{!subject}" maxlength="80"/><br/>
                <apex:inputField value="{!objEvent.ActivityDate}" /><br/>
                <apex:inputField value="{!objEvent.StartDateTime}" /><br/>
                <apex:inputField value="{!objEvent.Description}" /><br/>
                <apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($CurrentPage.parameters.start,':',''),'-',''),' ','T')}"/>
            </apex:pageblocksection>
        </apex:pageblock>
        
             <!---   <apex:inputField value="{!objEvent.starttime}" /> -->
                <apex:commandButton value="send" action="{!sendInvite}"/>
    </apex:form>
</apex:page>

Controller:-

public class SendEmail {
    public String sendTo { get; set; }
    public String Subject { get; set; }
    public Event objEvent{get;set;}
    public SendEmail() {}
    public PageReference sendInvite() {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {sendTo};
        mail.setToAddresses(toAddresses);
        mail.setSubject(Subject);
        mail.setPlainTextBody('');
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.filename = 'meeting.ics';
        attach.ContentType = 'text/calendar;';
        attach.inline = true;
        attach.body = invite();
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] {attach});
        Messaging.SendEmailResult[] er = Messaging.sendEmail(new Messaging.Email[] {mail});
        return null;
    }
    private Blob invite() {
        String txtInvite = '';
 
        txtInvite += 'BEGIN:VCALENDAR\n';
        txtInvite += 'PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\n';
        txtInvite += 'VERSION:2.0\n';
        txtInvite += 'METHOD:PUBLISH\n';
        txtInvite += 'X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n';
        txtInvite += 'BEGIN:VEVENT\n';
        txtInvite += 'CLASS:PUBLIC\n';
        txtInvite += 'CREATED:20150709T083709Z\n';
        txtInvite += 'DTEND:20150709T010000Z\n';
        txtInvite += 'DTSTAMP:20150708T203709Z\n';
        txtInvite += 'DTSTART:20150709T000000Z\n';
        txtInvite += 'LAST-MODIFIED:20150708T203709Z\n';
        txtInvite += 'LOCATION:Online\n';
        txtInvite += 'PRIORITY:5\n';
        txtInvite += 'SEQUENCE:0\n';
        txtInvite += 'SUMMARY;';
        txtInvite += 'LANGUAGE=en-us:Meeting\n';
        txtInvite += 'TRANSP:OPAQUE\n';
        txtInvite += 'UID:4036587160834EA4AE7848CBD028D1D200000000000000000000000000000000\n';
        txtInvite += 'X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><META NAME="Generator" CONTENT="MS Exchange Server version 08.00.0681.000"><TITLE></TITLE></HEAD><BODY><!-- Converted from text/plain format --></BODY></HTML>\n';
        txtInvite += 'X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n';
        txtInvite += 'X-MICROSOFT-CDO-IMPORTANCE:1\n';
        txtInvite += 'END:VEVENT\n';
        txtInvite += 'END:VCALENDAR';
 
        return Blob.valueOf(txtInvite);
    }
}
Hi all,

I am trying to display a line chart for Opportunity object fields- name,amount. I reffered an example. But am able to display only the data table and facing problem to display the line chart. Am even not getting any error.

Here is my code:-
--------------------------------

<apex:page controller="DynamicSalesChartController">
<apex:chart data="{!opportunities}" width="600" height="400">
     <apex:axis type="Category" position="left"   fields="Name"   title="Opportunities"/>
     <apex:axis type="Numeric"  position="bottom" fields="Amount" title="Amount"/>
     <apex:lineseries orientation="horizontal" axis="bottom" xField="Name" yField="Amount"/>
</apex:chart>
<apex:dataTable value="{!opportunities}" var="opportunity">
    <apex:column headerValue="Opportunity" value="{!opportunity.name}"/>
    <apex:column headerValue="Amount"      value="{!opportunity.amount}"/>
</apex:dataTable>    
</apex:page>


public class DynamicSalesChartController {
    
    // Get a set of Opportunities
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [SELECT name, type, amount, closedate FROM Opportunity]));
                setCon.setPageSize(20);
            }
            return setCon;
        }
        set;
    }
    
    public List<Opportunity> getOpportunities() {
         return (List<Opportunity>) setCon.getRecords();
    }
}
Hi,

Actually i need to generate records in account object based on the data present in the attached file, which wll be sent to Salesforce through email. I am trying to do so using Inbound Email Service, but am only able to read the body of the email but not the attachment data.
Hi all,

Actually i need to generate records in account object based on the data present in the attached file, which wll be sent to Salesforce through email. I am trying to do so using Inbound Email Service, but am only able to read the body of the email but not the attachment data.
Hello,
Here i have a vf page which displays two drop downs, i mean controlling picklist (Region) and dependent picklist(Fields).
I need to display another vf page in the same vf page when we select a field in second drop down.
Am able to redirect to another vf page when we select a field value. 
Instead of redirecting to another vf page using page reference, i want to display that vf page in the same page under the drop down fields section.
Here is my code

VF Page:-
-------------------------

<apex:page controller="TestDashboard">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection columns="2">
            
         <apex:outputLabel value="Region"/>
            <apex:pageblockSectionItem >                
                <apex:selectList size="1" value="{!Region}">
                    <apex:selectOptions value="{!Regions}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>                
            </apex:pageblockSectionItem>
                <apex:outputLabel value="Fields"/>
            
            <apex:selectList value="{!Field}" size="1" >
     <Apex:selectOptions value="{!item}"/>
    <apex:actionSupport event="onchange" action="{!redirect}" />    
     </apex:selectList>
        </apex:pageBlockSection>    
       
    </apex:pageBlock>

    </apex:form>

</apex:page>


Controller:-
--------------------

public class TestDashboard {
    public String Region {get;set;}
    public String Field {get;set;}
    public list<selectoption>item{get;set;}
    public TestDashboard()
{
    item=new list<selectoption>();
    item.add(new selectoption('','---None----'));
    item.add(new selectoption('SplitTabs','PipeLine'));
    item.add(new selectoption('MULChart','Commit'));
}
 
public pagereference redirect()
{
     PageReference pageRef= new PageReference('/apex/' +Field);
    pageRef.setredirect(true);
    return pageRef;
}
    public List<SelectOption> getRegions()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));        
        options.add(new SelectOption('A','Great Lakes(Tom Leone)'));
        options.add(new SelectOption('A','Metro NY/NJ(Rachel Sama)'));
        options.add(new SelectOption('A','Mid Atlantic(Rob Newman)'));
        options.add(new SelectOption('A','Mid West(Jim Stanley)'));
        options.add(new SelectOption('A','New England(Tony Messina)'));
        options.add(new SelectOption('A','South Central(Hector vallejo)'));
        options.add(new SelectOption('A','South East(Jeff Nelson)'));
        options.add(new SelectOption('A','Central(David Neuner)'));
        options.add(new SelectOption('A','Mountain Plains(Jared Holmes)'));
        options.add(new SelectOption('A','Northern California(Chad Petric)'));
        options.add(new SelectOption('A','N.Central(Michael Robinson)'));
        options.add(new SelectOption('A','North West(Rick Estes)'));
        options.add(new SelectOption('A','Southern California(Dennis Zanrosso)'));
        options.add(new SelectOption('A','South West(Chris Crospy)'));
        options.add(new SelectOption('A','US East'));
        options.add(new SelectOption('A','US West'));
        return options;
    } 
    
    public List<SelectOption> getFields()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(Region == 'A')
        {       
            options.add(new SelectOption('None','--- None ---'));
            options.add(new SelectOption('PipeLine','PipeLine'));
            options.add(new SelectOption('Actuals','Actuals'));
            options.add(new SelectOption('Commit','Commit'));
            options.add(new SelectOption('OP(Operating Plan','OP(Operating Plan)'));
            options.add(new SelectOption('Run Rate Opp','Run Rate Opp'));
            options.add(new SelectOption('Quote Min Vlaue','Quote Min Vlaue'));
            options.add(new SelectOption('No.of Opp With Quotes','No.of Opp With Quotes'));
            options.add(new SelectOption('No.of Quotes','No.of Quotes'));
            options.add(new SelectOption('BestCase','BestCase'));
            options.add(new SelectOption('Spec Dollars','Spec Dollars'));
            options.add(new SelectOption('BestCase Count','BestCase Count'));
            options.add(new SelectOption('No.of Opp with Spec Flag','No.of Opp with Spec Flag'));
            options.add(new SelectOption('% vCommit','% vCommit'));
            options.add(new SelectOption('% vOP','% vOP'));
            options.add(new SelectOption('Calls Logged','Calls Logged'));
            
        }
        
        else if(Region == 'KL')
        {       
            options.add(new SelectOption('COA','Coachin'));
            options.add(new SelectOption('MVL','Mavelikara'));
        }
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }      
        return options;
    }
    
}
Hi All,
Actually i need to get an email with attachment into salesforce using email services. The data in the attachment is a list of account names,phone,billingcity. Then after i want to create records on account object automatically based on the data in the attachment. I got how to receive an attachment using email service. And now how to populate records from attachment?

Here is my code (Email Service):-

global class ProcessContactApplicantEmail implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.Inboundenvelope envelope) {
     Account account;
     Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

          try {
                 if ([select count() from Account where Name =:email.subject] == 0) {
                       account = new Account();
                       account.Name = email.subject;
                       insert account;
                 } else {
                       account = [select Id from Account where Name =:email.subject];
                 }
       for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
             Attachment attachment = new Attachment(); 
             attachment.Name = tAttachment.fileName;
             attachment.Body = Blob.valueOf(tAttachment.body);
             attachment.ParentId = account.Id;
             insert attachment;
       }
       for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
             Attachment attachment = new Attachment();
           attachment.Name = bAttachment.fileName;
            attachment.Body = bAttachment.body;
             attachment.ParentId = account.Id;
             insert attachment;
       }
       Note note = new Note();
       note.Title = email.fromName + ' (' + DateTime.now() + ')';
       note.Body = email.plainTextBody;
       note.ParentId = account.Id;
       insert note;
      result.success = true;
     } catch (Exception e) {
           result.success = false;
           
    }

    return result;
  }
}

 
Hii All,
Actually i need to get attachment consisting of listof contact names,phone,mailingcity from inbound mail (i.e.,email services) and need to generate records from that attachment automatically. I have an apex class regarding getting attachment from inbound mail. But not able to retrieve records from attachment. Can anyone help in this?

Here is the code


global class ContactEmailservice implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope envelope) {

    Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();

    Contact contact = new Contact();
    contact.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
    contact.LastName = email.fromname.substring(email.fromname.indexOf(' '));
    contact.Email = envelope.fromAddress;
       
    insert contact;

    System.debug('====> Created contact '+contact.Id);

    Attachment attachment = new Attachment();
    attachment.ParentId = contact.Id;
    attachment.Name = email.subject;
    attachment.Body = Blob.valueOf(email.HtmlBody);
    insert attachment;
    return result;
  }
}
hi all... i need to get a new detail page layout for account record when we select rating value as "Warm". I did this by creating a new record type and assigning this with workflow field update. but i need to perform this task without changing the standard record type of account. 

Thanks
Bittu
hi all... i need to get a new detail page layout for account record when we select rating value as "Warm". I did this by creating a new record type and assigning this with workflow field update. but i need to perform this task without changing the standard record type of account. 

Thanks
Bittu
hi all... i need to get a new detail page layout for account record when we select rating value as "Warm". I did this by creating a new record type and assigning this with workflow field update. but i need to perform this task without changing the standard record type of account. 

Thanks
Bittu
hi all... i need to get a new detail page layout for account record when we select rating value as "Warm". I did this by creating a new record type and assigning this with workflow field update. but i need to perform this task without changing the standard record type of account. 

Thanks
Bittu
hiii all.... i need to reverse a given string with apex class using array concept 
  • April 24, 2015
  • Like
  • 0
hi all...
         actually when we delete an account, i need to create a new contact with the details of deleted account. how can we do this using apex triggers
  • April 09, 2015
  • Like
  • 0
i need to delete all the questions asked by me in the forums. how can i do this?
this is my link

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AfDGIA0
  • March 12, 2015
  • Like
  • 0
Hi all,

I need to add a custom field of Account object to Standard Task&Event Report type. How can i do this?
Hi All,

I am working on a Test Class and not able to cover the list in private method.

Controller:-
----------------
public class addWholesaleForcastController {
    public string selectedYear{get;set;}
    string recordTypeId = '';
    string retURL = '';
    set<String> setRegion = new set<String>();
    public String dbAction{get;set;}
    public addWholesaleForcastController(ApexPages.StandardController controller) {
        getRegions();
        selectedYear = ApexPages.currentPage().getParameters().get('year');
        retURL = ApexPages.currentPage().getParameters().get('retURL');
        List<RecordType> lstRt = [Select Id from RecordType where sObjectType='SalesForecastData__c'
            and DeveloperName='Monthwhl'];
        if(lstRt.size()>0){
            recordTypeId = lstRt[0].Id;
        }
        getWholesaleData();
    }
    public PageReference cancel(){
        PageReference P = new PageReference(retURL);
        return P;
    }
    public PageReference save(){
        try{
            List<SalesForecastData__c> lstData = new List<SalesForecastData__c>();
            if(lstWholesale.size()>0){
                for(Wholesale data:lstWholesale){
                    lstdata.add(data.data);
                }
            }
            if(lstdata.size()>0) upsert lstdata;
            //////////////
            PageReference P = new PageReference(retURL);
            return P;
        }
        catch(Exception ex){
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,ex.getMessage()));
            return null;
        }
    }
    public List<Wholesale> lstWholesale{get;set;}
    void getWholesaleData(){
        lstWholesale = new List<Wholesale>();
        if(common.NVL(selectedYear) != ''){
            List<SalesForecastData__c> lstData = [Select Id, Name, Region__c, Region_Text__c,
                Jan__c, Feb__c, Mar__c, Apr__c, May__c, Jun__c, Jul__c, Aug__c, Sep__c,
                Oct__c, Nov__c, Dec__c, Year__c
                from SalesForecastData__c Where Year__c =:selectedYear and RecordtypeId=:recordTypeId];
            if(lstData.size()>0){
                dbAction = 'Update';
                for(SalesForecastData__c data:lstData){
                    lstWholesale.add(new Wholesale(data));
                }
            }
            else{
                dbAction = 'Add';
                if(setRegion.size()>0){
                    for(String rgn:setRegion){
                        SalesForecastData__c data = new SalesForecastData__c();
                        data.Year__c = selectedYear;
                        data.Region__c = rgn;
                        data.RecordtypeId=recordTypeId;
                        lstWholesale.add(new Wholesale(data));
                    }
                }
            }
        }
    }
    void getRegions(){
        setRegion.add('01');
        setRegion.add('02');
        setRegion.add('03');
        setRegion.add('04');
        setRegion.add('05');
        setRegion.add('06');
        setRegion.add('07');
        setRegion.add('08');
        setRegion.add('09');
        setRegion.add('10');
        setRegion.add('11');
        setRegion.add('12');
        setRegion.add('13');
        setRegion.add('14');
        setRegion.add('15');
        setRegion.add('16');
        setRegion.add('Cent');
        setRegion.add('East');
        setRegion.add('None');
        setRegion.add('S&G');
        setRegion.add('West');
    }
    class Wholesale{
        public SalesForecastData__c data{get;set;}
        public Wholesale(SalesForecastData__c data){
            this.data = data;
        }
    }
}

Test Class:-
------------------------
@isTest
public class Test_WholesaleForcast {
static testMethod void Test_WholesaleForcast2(){
        List<RecordType> lstRT2 = [Select Id from RecordType Where DeveloperName='Monthwhl' and sObjectType='SalesForecastData__c'];
        String recordtypeId = 'Monthwhl';
        SalesForecastData__c Sales2 = new SalesForecastData__c(Year__c = '2014');
               insert sales2;
        Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(sales2);
        addWholesaleForcastController  addwhlsale = new addWholesaleForcastController (sc);
        addwhlsale.save();
        addwhlsale.dbAction = 'abc';
        addwhlsale.selectedYear = '2014';
        Test.stopTest();
    }

}
Hi,

Actually i need to generate records in account object based on the data present in the attached file, which wll be sent to Salesforce through email. I am trying to do so using Inbound Email Service, but am only able to read the body of the email but not the attachment data.
Hi all,

Actually i need to generate records in account object based on the data present in the attached file, which wll be sent to Salesforce through email. I am trying to do so using Inbound Email Service, but am only able to read the body of the email but not the attachment data.
Hello,
Here i have a vf page which displays two drop downs, i mean controlling picklist (Region) and dependent picklist(Fields).
I need to display another vf page in the same vf page when we select a field in second drop down.
Am able to redirect to another vf page when we select a field value. 
Instead of redirecting to another vf page using page reference, i want to display that vf page in the same page under the drop down fields section.
Here is my code

VF Page:-
-------------------------

<apex:page controller="TestDashboard">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection columns="2">
            
         <apex:outputLabel value="Region"/>
            <apex:pageblockSectionItem >                
                <apex:selectList size="1" value="{!Region}">
                    <apex:selectOptions value="{!Regions}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>                
            </apex:pageblockSectionItem>
                <apex:outputLabel value="Fields"/>
            
            <apex:selectList value="{!Field}" size="1" >
     <Apex:selectOptions value="{!item}"/>
    <apex:actionSupport event="onchange" action="{!redirect}" />    
     </apex:selectList>
        </apex:pageBlockSection>    
       
    </apex:pageBlock>

    </apex:form>

</apex:page>


Controller:-
--------------------

public class TestDashboard {
    public String Region {get;set;}
    public String Field {get;set;}
    public list<selectoption>item{get;set;}
    public TestDashboard()
{
    item=new list<selectoption>();
    item.add(new selectoption('','---None----'));
    item.add(new selectoption('SplitTabs','PipeLine'));
    item.add(new selectoption('MULChart','Commit'));
}
 
public pagereference redirect()
{
     PageReference pageRef= new PageReference('/apex/' +Field);
    pageRef.setredirect(true);
    return pageRef;
}
    public List<SelectOption> getRegions()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));        
        options.add(new SelectOption('A','Great Lakes(Tom Leone)'));
        options.add(new SelectOption('A','Metro NY/NJ(Rachel Sama)'));
        options.add(new SelectOption('A','Mid Atlantic(Rob Newman)'));
        options.add(new SelectOption('A','Mid West(Jim Stanley)'));
        options.add(new SelectOption('A','New England(Tony Messina)'));
        options.add(new SelectOption('A','South Central(Hector vallejo)'));
        options.add(new SelectOption('A','South East(Jeff Nelson)'));
        options.add(new SelectOption('A','Central(David Neuner)'));
        options.add(new SelectOption('A','Mountain Plains(Jared Holmes)'));
        options.add(new SelectOption('A','Northern California(Chad Petric)'));
        options.add(new SelectOption('A','N.Central(Michael Robinson)'));
        options.add(new SelectOption('A','North West(Rick Estes)'));
        options.add(new SelectOption('A','Southern California(Dennis Zanrosso)'));
        options.add(new SelectOption('A','South West(Chris Crospy)'));
        options.add(new SelectOption('A','US East'));
        options.add(new SelectOption('A','US West'));
        return options;
    } 
    
    public List<SelectOption> getFields()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(Region == 'A')
        {       
            options.add(new SelectOption('None','--- None ---'));
            options.add(new SelectOption('PipeLine','PipeLine'));
            options.add(new SelectOption('Actuals','Actuals'));
            options.add(new SelectOption('Commit','Commit'));
            options.add(new SelectOption('OP(Operating Plan','OP(Operating Plan)'));
            options.add(new SelectOption('Run Rate Opp','Run Rate Opp'));
            options.add(new SelectOption('Quote Min Vlaue','Quote Min Vlaue'));
            options.add(new SelectOption('No.of Opp With Quotes','No.of Opp With Quotes'));
            options.add(new SelectOption('No.of Quotes','No.of Quotes'));
            options.add(new SelectOption('BestCase','BestCase'));
            options.add(new SelectOption('Spec Dollars','Spec Dollars'));
            options.add(new SelectOption('BestCase Count','BestCase Count'));
            options.add(new SelectOption('No.of Opp with Spec Flag','No.of Opp with Spec Flag'));
            options.add(new SelectOption('% vCommit','% vCommit'));
            options.add(new SelectOption('% vOP','% vOP'));
            options.add(new SelectOption('Calls Logged','Calls Logged'));
            
        }
        
        else if(Region == 'KL')
        {       
            options.add(new SelectOption('COA','Coachin'));
            options.add(new SelectOption('MVL','Mavelikara'));
        }
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }      
        return options;
    }
    
}
Hi All,
Actually i need to get an email with attachment into salesforce using email services. The data in the attachment is a list of account names,phone,billingcity. Then after i want to create records on account object automatically based on the data in the attachment. I got how to receive an attachment using email service. And now how to populate records from attachment?

Here is my code (Email Service):-

global class ProcessContactApplicantEmail implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.Inboundenvelope envelope) {
     Account account;
     Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

          try {
                 if ([select count() from Account where Name =:email.subject] == 0) {
                       account = new Account();
                       account.Name = email.subject;
                       insert account;
                 } else {
                       account = [select Id from Account where Name =:email.subject];
                 }
       for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
             Attachment attachment = new Attachment(); 
             attachment.Name = tAttachment.fileName;
             attachment.Body = Blob.valueOf(tAttachment.body);
             attachment.ParentId = account.Id;
             insert attachment;
       }
       for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
             Attachment attachment = new Attachment();
           attachment.Name = bAttachment.fileName;
            attachment.Body = bAttachment.body;
             attachment.ParentId = account.Id;
             insert attachment;
       }
       Note note = new Note();
       note.Title = email.fromName + ' (' + DateTime.now() + ')';
       note.Body = email.plainTextBody;
       note.ParentId = account.Id;
       insert note;
      result.success = true;
     } catch (Exception e) {
           result.success = false;
           
    }

    return result;
  }
}

 
Hii All,
Actually i need to get attachment consisting of listof contact names,phone,mailingcity from inbound mail (i.e.,email services) and need to generate records from that attachment automatically. I have an apex class regarding getting attachment from inbound mail. But not able to retrieve records from attachment. Can anyone help in this?

Here is the code


global class ContactEmailservice implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope envelope) {

    Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();

    Contact contact = new Contact();
    contact.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
    contact.LastName = email.fromname.substring(email.fromname.indexOf(' '));
    contact.Email = envelope.fromAddress;
       
    insert contact;

    System.debug('====> Created contact '+contact.Id);

    Attachment attachment = new Attachment();
    attachment.ParentId = contact.Id;
    attachment.Name = email.subject;
    attachment.Body = Blob.valueOf(email.HtmlBody);
    insert attachment;
    return result;
  }
}
hiii all.... i need to reverse a given string with apex class using array concept 
  • April 24, 2015
  • Like
  • 0
hi all...
         actually when we delete an account, i need to create a new contact with the details of deleted account. how can we do this using apex triggers
  • April 09, 2015
  • Like
  • 0
i need to delete all the questions asked by me in the forums. how can i do this?
this is my link

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AfDGIA0
  • March 12, 2015
  • Like
  • 0
Hi

I want to read Email Inbound attachment file  in apex class and create new object's records.
Since the file is in ANSI Format it is considered as binary attachment even if the file is a text file.

I want to read the body of the file.

I have checked that Apex Class version 19.0  can able to read the Blob by Blob.toString() method, but greater version cannot able to read. It is throwing exception as "BLOB is not a valid UTF-8 string".

I want to use ANSI file foramt as attachment since these files are coming from different system automatically.

Please help me to read out the content of email inbound attachment file.

Hi

I am trying to read the content of an attachment from an apex class. 

 Attachment att=   [Select Id,a.ParentId, a.Name,a.body,a.ContentType From Attachment a where ParentId=:contactId limit 1];
           System.debug('Attachment body : '+ att.body);
        System.debug('Attachment body : '+ att.ContentType);

 the attachment body  content is displayed as :Blob[176680].
the body of the attachment is base64. I want to see the content of the body in plain english.

 

Thanks