• riaz
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Amazon salesforce toolkit error. i am getting this error by cliking the tab awss3samples
Web service callout failed: WebService returned a SOAP Fault: Your account is not signed up for the S3 service. You must sign up before you can use S3. faultcode=soapenv:Client.NotSignedUp faultactor=

is any one who wish to help me, i have free acount on amazon
 
  • November 13, 2014
  • Like
  • 0
// Creates an Opportunity record when a Lead record is converted
public class MyLead {
    public static void convertLead(Lead[] leads) {
      Database.LeadConvert leadConvert = new Database.LeadConvert();
      for (Lead lead :leads) {
        if (!(lead.IsConverted)) {
          // Check if an account exists with email. Attach Contact and Account, convert Lead.
          Contact[] myContacts = [SELECT Id, AccountId FROM Contact WHERE Email = :lead.Email Limit 1];
          if (myContacts.size() == 1) {
            System.debug('Existing Contact');
            MyLead.attachExistingConvert(lead, myContacts[0]);
          }
          else {
            System.debug('No existing contact');
            if (lead.Auto_Convert__c) {
               
    
              MyLead.addCampaign(lead, lead.Campaign__c);
             
              leadConvert.setLeadId(lead.Id);
              leadConvert.setConvertedStatus('Closed - Converted');
              Database.LeadConvertResult lcResult = Database.ConvertLead(leadConvert);
             
              // Populate the newly created records with extra data.
              MyLead.updateOpportunity(lead, lcResult);
              Company__c myCompany = [SELECT Id FROM Company__c WHERE Company_Id__c = :lead.Company_Id__c];
              MyLead.updateContact(lead, lcResult, myCompany);
              // Must update the Company before Account otherwise the Account lookup will fail.
              MyLead.updateCompany(lead, lcResult, myCompany);
              MyLead.updateAccount(lead, lcResult, myCompany);
            }
          }
        }
      }
    }

    // Attaches Lead to Contact and Account if matched by Email, converts Lead and creates opportunity if it doesn't exist.
    public static void attachExistingConvert(Lead lead, Contact contact) {
        MyLead.addCampaign(lead, lead.Campaign__c);
        Database.leadConvert leadConvert = new Database.LeadConvert();
        leadConvert.setLeadId(lead.Id);
        leadConvert.setConvertedStatus('Closed - Converted');
        leadConvert.setContactId(contact.Id);
        leadConvert.setAccountId(contact.AccountId);
        leadConvert.setSendNotificationEmail(True);
        // Do not create an opportunity if any exist.
        Opportunity[] myOpportunity = [SELECT Id FROM Opportunity WHERE AccountId = :contact.AccountId];
        if (myOpportunity.size() > 0) {
          leadConvert.setDoNotCreateOpportunity(True);
        }
        leadConvert.setLeadId(lead.Id);
        Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);
        // If we created an opportunity, update it with extra stuff.
        if (leadConvert.isDoNotCreateOpportunity() == False) {
          MyLead.updateOpportunity(lead, leadConvertResult);
        }
    }
   
    // Updates the newly created Opportunity with extra data
    public static void updateOpportunity(Lead lead, Database.LeadConvertResult lcResult) {
      Opportunity myOpportunity = [SELECT Id, StageName FROM Opportunity WHERE Id = :lcResult.opportunityId];
      myOpportunity.Name = 'Online Upgrade';
      myOpportunity.TrialStart__c = lead.CreatedDate.date();
      //myOpportunity.Amount = lead.Monthly_Revenue__c;
      myOpportunity.Amount = lead.Amount__c;
      myOpportunity.Type = 'New Business';
      myOpportunity.LeadSource = 'Website';
      myOpportunity.Order__c = lead.Order__c;
      DateTime dt = System.now();
      Date d = dt.date();
      myOpportunity.CloseDate = d;
      myOpportunity.StageName = lead.Agency__c ? 'Won (Agency)' : 'Won (End User)';
      myOpportunity.Probability = 100;

      update myOpportunity;
    }
   
    // Updates the newly created Account with extra data
    public static void updateAccount(Lead lead, Database.LeadConvertResult lcResult, Company__c myCompany) {
      Account myAccount = [SELECT Id FROM Account WHERE Id = :lcResult.accountId];
      myAccount.Type = 'Customer';
      myAccount.ASEO_Company_Id__c = lead.Company_Id__c;
      myAccount.Company__c = myCompany.Id; // Setting the company will cause the company account lookup to fail
      myAccount.Order__c = lead.Order__c;

      update myAccount;
    }
   
    // Updates the newly created Contact with extra data
    public static void updateContact(Lead lead, Database.LeadConvertResult lcResult, Company__c myCompany) {
      Contact myContact = [SELECT Id FROM Contact WHERE Id = :lcResult.contactId];
      myContact.ASEO_Company_Id__c = lead.Company_Id__c;
      myContact.Company__c = myCompany.Id;

      update myContact;
    }

    // Updates the Company with extra data
    public static void updateCompany(Lead lead, Database.LeadConvertResult lcResult, Company__c myCompany) {
      myCompany.Account__c = lcResult.accountId;

      update myCompany;
    }
   
    // Adds a lead to a campaign
    public static void addCampaign(Lead lead, String campaign) {
     
      Campaign[] myCampaigns = [Select Id FROM Campaign WHERE Name = :campaign LIMIT 1];
      if (myCampaigns.size() == 1) {
        CampaignMember campaignMember = new CampaignMember (campaignId=myCampaigns[0].Id, leadId=lead.Id);
        insert campaignMember;
      }
    }
    
    // Create campaign members from leads. Campaign comes from lead.Campaign__c.
    public static void addCampaignMembers(Lead[] leads) {
      for (Lead lead :leads) {
        // Might want to query Campaigns table instead.
        //Set<String> campaigns = new Set<String>();
        //campaigns.add('Freemium');
        Campaign[] myCampaigns = [SELECT Id FROM Campaign WHERE Name = :lead.Campaign__c LIMIT 1];
       
        //if (campaigns.contains(lead.Campaign__c)) {
        if (myCampaigns.size() == 1) {
          MyLead.addCampaign(lead, lead.Campaign__c);
        }
      }
     }
   
}

and trigger on lead 

trigger LeadTrigger on Lead (after insert, after update) {
    Lead[] leads = Trigger.new;
    //MyLead.createOpportunity(leads);
    MyLead.convertLead(leads);
}
  • May 22, 2014
  • Like
  • 0
How can i add two standardcontroller in my visual for pages, i know i can do it with extension, but i dont want to use extensions with my page
  • May 07, 2014
  • Like
  • 0
How can i add two standardcontroller in my visual for pages, i know i can do it with extension, but i dont want to use extensions with my page
  • May 07, 2014
  • Like
  • 0

Hi Everyone,

 

I need to create a dropdown field on Visualforce page which should display the list of Users based on a query.

Then I need to use the chosen  value in my Controller.

 

How to achieve this??

Plz help its urgent 

 

Thanks,

Ankit

Hi,

 

I have a bunch of VF pages. I have created test class and have added test methods for each page. However I would like to take this further to meet the expected test %.

 

My VF pages has custom controllers assigned. In the custon controller class there are child classes declared.

What should be added to the below test class to increase test %.

 

Thanks.

 

Visual Force Page

public class TripByMonth{
                  
  Private List <AggregateResult> LstTripLegs=new List <AggregateResult>();
  Private List <AggregateResult> LstTripLegCities=new List <AggregateResult>();
  Private List <MonthlyTrip> lstJanTrips=new List <MonthlyTrip>();
  Private List <MonthlyTrip> lstFebTrips=new List <MonthlyTrip>();
  Private List <MonthlyTripArray> lstAllTrips=new List <MonthlyTripArray>();


  
//Constructor of the class
  PublictTripByMonth(){
    LstTripLegs=[SELECT To_City__r.Name TravelTo,Trip__r.Analyst__r.Name Analyst, Calendar_Month(Trip_leg_From_date__c)cal_mon                   
            FROM Leg__C GROUP BY Calendar_Month(Trip_leg_From_date__c), To_City__r.Name,Trip__r.Analyst__r.Name
            ORDER BY To_City__r.Name];

   LstTripLegCities=[SELECT To_City__r.Name TravelTo, Count(Trip__r.Analyst__r.Name) CntAn,Calendar_Month(Trip_leg_From_date__c)cal_mon                   
            FROM Leg__C GROUP BY Calendar_Month(Trip_leg_From_date__c), To_City__r.Name
            ORDER BY To_City__r.Name];
            
  }
//Trip record list
   Public List <LegInfo> getLegsForReport(){
     List <LegInfo> LstLegs = new List <LegInfo>();
     
     for (AggregateResult ARs:LstTripLegs){
       LegInfo ObjLegInfo=new LegInfo(ARs);
       LstLegs.Add (ObjLegInfo);       
     }     
     Return LstLegs;     
   }
//Create All Trips array   
  Public List <MonthlyTripArray> getAllTrips(){
    String stOldCity='';
    String stJanAnalysts='';
    String stFebAnalysts='';
    String stMarAnalysts='';
    String stAprAnalysts='';

    
    for (AggregateResult ARJan:LstTripLegs){
       if(stOldCity ==''){
         stOldCity = (String)ARJan.get('TravelTo');
       }
       if(stOldCity != (String)ARJan.get('TravelTo')){
          MonthlyTripArray ObjAllMonthlyTrip=new MonthlyTripArray (stOldCity,StJanAnalysts,StFebAnalysts,StMarAnalysts,StAprAnalysts);
          lstAllTrips.Add (ObjAllMonthlyTrip);                    
          stOldCity = (String)ARJan.get('TravelTo');
          StJanAnalysts='';
          StFebAnalysts='';
          StMarAnalysts='';
          StAprAnalysts='';          
          Continue;
       }        
       if ((Integer) ARJan.get('cal_mon') == 1) {       
        StJanAnalysts = StJanAnalysts + (String)ARJan.get('Analyst')+ '<br>';                   
       }       
       if ((Integer) ARJan.get('cal_mon') == 2) {       
        StFebAnalysts = StFebAnalysts + (String)ARJan.get('Analyst')+ '<br>';                   
       }
    }    
  return lstAllTrips;  
}
//****************************************************
  Class MonthlyTripArray{
    Public String CityName{get; set;}
    Public String JanAnalysts{get; set;}
    Public String FebAnalysts{get; set;}


    Public MonthlyTripArray(String Cn, String JAn, String FAn){
      CityName = Cn;
      JanAnalysts=JAn;
      FebAnalysts=FAn;
    }
      
  }
//****************************************************
  Class MonthlyTrip{
    Public String CityName{get; set;}
    Public String Analysts{get; set;}
    
    Public MonthlyTrip(String Cn, String An){
      CityName = Cn;
      Analysts=An;      
    }
      
  }   
}

 

Test Class method-

 Public static  testMethod void VFPageTest_TripDashboard(){
     PageReference pgRef = Page.TripDashboard;
     Test.setCurrentPageReference (pgRef);
     TripByMonth myPgCont = new TripByMonth();  
     
   }

Hi,

 

Is it possible to use multiple standard controller in a VF page..

 

i.e. something like this..

<apex:page standardController="Quote" standardController="Account"

 

 

 

Thanks,

Del

Hi all,

 

On my Visualforce page, I would like to display the account names in a dropdown list.

 

For each account record, I have a custom field called display. If that display box is ticked, I would like to display the name of the account in the list. 

 

Is there a way to do that please? 

 

Many thanks 

 

  • February 14, 2010
  • Like
  • 0