• levi6db
  • NEWBIE
  • 125 Points
  • Member since 2009

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 40
    Replies

HI,

 

I want to write a validation rule. The scenario is  lead status must be changed from open with in 48 hours and if not the refferal will loose his visibility. How can i do this?

Hi all,

 

We are looking to hire a temporary developer to write classes & triggers for our Salesforce.com and Oracle EBS11 integration. The model is already in place, but we do need some extra help.

 

Looking find someone within the next few months.


Please let me know. 

Thanks, 
Alex Searcy 

Hi all,

 

I created an object called Locations that pulls data from another custom object called FNL.  I created a button on the Opportunity object that will allow a rep to lookup a given FNL location and create a Location item.  I currently have the following features working: The FNL search fields, the matching values based on the search and the existing Locations that are already associated to the Opportunity.

 

What I am having trouble with is being able to create checkboxes next to the matching values that are returned that will allow me to add them to the Opportunity.

 

public class LocationSearchController {

 public PageReference Cancel() {
        return null;
    }

        public Opportunity o { get; set; }
    Id myid= ApexPages.currentPage().getParameters().get('id');
    
    public PageReference ViewData() {

    return null;
    }
     
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of FNL to display
  public List<FNL__c> fnl {get;set;}
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by. defaults to Name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public LocationSearchController() {
    soql = 'select Name, FNL_Suite__c, FNL_City__c, FNL_State__c, FNL_Zip__c, Building_Code__c from FNL__c where Name != null';
    runQuery();
   
    o = [select Id, Name, OwnerId, Account.Name, RecordType.Name, Existing_Order_Number__c, AboveNet_Order_Number__c, Quote_MRC_Total__c, 
                 Quote_NRC_Total__c, TechChange__c, Commencement_Date__c, PrepaymentAmount__c, ImplementationComments__c, BillingComments__c 
                 from Opportunity 
                 where id = :myid];     
  }
  
  public Opportunity getOpportunity() {
            return o;
  }
 
 
    //Our collection of the class/wrapper objects cLoctact 
    public List<cLocation> locationList {get; set;}

    //This method uses a simple SOQL query to return a List of Contacts
    public List<cLocation> getLocations() {
        if(locationList == null) {
            locationList = new List<cLocation>();
            for(Location__c c : [select Id, Street__c, City__c, State__c, zip__c, Entrances_Required__c, Location__c, Proposed_Demarc__c,
                            Country__c, FNL_Building_Code__c, Location_Type__c, Available_Entrance__c, Building_Fiber_Demarc__c, Name, 
                            Building_is_OnNet__c, Building_Type__c, Suite__c, FNL_Street__c from Location__c where Account__c = :o.AccountId]) {
                // As each contact is processed we create a new cLoctact object and add it to the contactList
                locationList.add(new cLocation(c));
            }
        }
        return locationList;
    }
   
     public PageReference processSelected() {

        //We create a new list of Locations that we be populated only with FNL if they are selected
        List<Location__c> selectedLocations = new List<Location__c>();

        //We will cycle through our list of cLocations and will check to see if the selected property is set to true, if it is we add the FNL to the selectedLocations list
        for(cLocation cLoc : getLocations()) {
            if(cLoc.selected == true) {
                selectedLocations.add(cLoc.loc);
            }
        }

        // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
        List <Location__c> newloc = new List<Location__c>();

        for(Location__c loc : selectedLocations) {
            
            Location__c nloc; 
            nloc = loc.clone(false);
            nloc.Opportunity__c = o.Id;
            nloc.Account__c = null;
            
            newloc.add(nloc);
        }
        
        insert newloc;
        return null;
    }

//Our collection of the class/wrapper objects cLocations 
    public List<dfnl> fnlList {get; set;}

    //This method uses a simple SOQL query to return a List of FNL
    public List<dfnl> getfnl() {
        if(fnlList == null) {
            fnlList = new List<dfnl>();
               for(FNL__c d : Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20') ) 
            {
                // As each contact is processed we create a new cFNL object and add it to the Location List
                fnlList.add(new dfnl(d));
             }
        }
        return fnlList;
    }
   
     public PageReference processSelectedf() {

        //We create a new list of Contacts that we be populated only with Contacts if they are selected
        List<FNL__c> selectedfnl = new List<FNL__c>();

        //We will cycle through our list of cLoctacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedLocations list
        for(dfnl dF : getfnl()) {
            if(dF.selected == true) {
                selectedfnl.add(dF.fnl2);
            }
        }

        // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
        List <Location__c> newloc1 = new List<Location__c>();

        for(FNL__c fnl : selectedfnl) {
            
            Location__c nloc1;
            nloc1.Access_Type__c = fnl.Access_Type__c;
            nloc1.Assets__c = fnl.Assets__c;
            nloc1.FNL_Building_Code__c = fnl.Building_Code__c;
            nloc1.Building_Fiber_Demarc__c = fnl.Building_Fiber_Demarc__c;
            nloc1.Building_Type__c = fnl.Building_Type__c;
            nloc1.Datacenter__c = fnl.Datacenter__c;
            nloc1.Entrances_Required__c = fnl.Entrance__c;
            nloc1.Street__c = fnl.FNL_Street__c;
            nloc1.Suite__c = fnl.FNL_Suite__c;
            nloc1.City__c = fnl.FNL_City__c;
            nloc1.State__c = fnl.FNL_State__c;
            nloc1.Zip__c = fnl.FNL_Zip__c;
            nloc1.Country__c = fnl.FNL_Country__c;
            nloc1.IP_POP__c = fnl.IP_POP__c;
            nloc1.IP_VPOP__c = fnl.IP_VPOP__c;
            nloc1.LH_POP__c = fnl.LH_POP__c;
            nloc1.LH_VPOP__c = fnl.LH_VPOP__c;
            nloc1.Opportunity__c = o.Id;
            nloc1.Account__c = null;
            
            newloc1.add(nloc1);
        }
        
        insert newloc1;
        return null;
    }


    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class cLocation {
        public Location__c loc {get; set;}
        public Boolean selected {get; set;}

        //This is the contructor method. When we create a new cLoctact object we pass a Contact that is set to the con property. We also set the selected value to false
        public cLocation(Location__c c) {
            loc = c;
            selected = false;
         }
    }
     
      // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class dFNL {
        public FNL__c fnl2 {get; set;}
        public Boolean selected {get; set;}

     //This is the contructor method. When we create a new cLoctact object we pass a Contact that is set to the con property. We also set the selected value to false
        public dFNL(FNL__c d) {
            fnl2 = d;
            selected = false;
         }
    }
  
     
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      fnl = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
 
    String Name = Apexpages.currentPage().getParameters().get('Name');
    String fnlcity= Apexpages.currentPage().getParameters().get('fnlcity');
    String buildingcode= Apexpages.currentPage().getParameters().get('buildingcode');
 
    soql = 'select Name, FNL_Suite__c, FNL_City__c, FNL_State__c, FNL_Zip__c, Building_Code__c from FNL__c where Name != null';
    if (!Name.equals(''))
      soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
    if (!fnlcity.equals(''))
      soql += ' and FNL_City__c LIKE \''+String.escapeSingleQuotes(fnlcity)+'%\'';
    if (!buildingcode.equals(''))
      soql += ' and Building_Code__c LIKE \''+String.escapeSingleQuotes(buildingcode)+'%\''; 
 
    // run the query again
    runQuery();

    return null;
  }
 

}

 

<apex:page controller="LocationSearchController" sidebar="false">
 
   <apex:form >
      <apex:pageBlock >
         <apex:pageBlockButtons >
            <apex:commandButton value="Add Selected Location to Opportunity" action="{!processSelected}" rerender="table" onclick="window.top.close()" oncomplete="javascript&colon;closeRefresh('{!Opportunity.Id}');"/>
            <apex:commandButton value="Cancel" action="{!Cancel}" rerender="table" onclick="window.top.close();"/>
         </apex:pageBlockButtons>
         <!-- In our table we are displaying the cContact records -->
         <apex:pageBlockTable value="{!locations}" var="c" id="table">
            <apex:column >
            <!-- This is our selected Boolean property in our wrapper class -->
             <apex:inputCheckbox value="{!c.selected}"/>
            </apex:column>
                <!-- This is how we access the contact values within our cContact container/wrapper -->
                   <apex:column value="{!c.loc.Name}" />
                   <apex:column value="{!c.loc.Street__c}" />
                   <apex:column value="{!c.loc.City__c}" />
                   <apex:column value="{!c.loc.State__c}" />
         </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
    
   <apex:form >
      <apex:pageMessages id="errors" />
 
      <apex:pageBlock title="FNL Lookup" mode="edit">
         <table width="100%" border="0">
            <tr>  
               <td width="200" valign="top">
                  <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                     <script type="text/javascript">
                        function doSearch() {
                        searchServer(
                        document.getElementById("Name").value,
                        document.getElementById("fnlcity").value,
                        document.getElementById("buildingcode").value);
                        } 
                     </script> 
 
                     <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                        <apex:param name="Name" value="" />
                        <apex:param name="fnlcity" value="" />
                        <apex:param name="buildingcode" value="" />
                     </apex:actionFunction>
 
                     <table cellpadding="2" cellspacing="2">
                        <tr>
                           <td style="font-weight:bold;">Street<br/>
                              <input type="text" id="Name" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">City<br/>
                              <input type="text" id="fnlcity" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Building Code<br/>
                              <input type="text" id="buildingcode" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                     </table>
                  </apex:pageBlock>
               </td>
                 <td valign="top">
                    <apex:pageBlock mode="edit" id="results">
                    <!-- In our table we are displaying the cContact records -->
                       <apex:pageBlockTable value="{!fnl}" var="d" id="FNLtable">

                            <apex:column value="{!d.Name}" />
                            <apex:column value="{!d.FNL_Suite__c}" />
                            <apex:column value="{!d.FNL_City__c}" />
                            <apex:column value="{!d.FNL_State__c}" />
                            <apex:column value="{!d.FNL_Zip__c}" />
                            <apex:column value="{!d.Building_Code__c}" />
                       </apex:pageBlockTable>
                       <apex:pageBlockButtons >
                          <apex:commandButton value="Add Selected Location to Opportunity" action="{!processSelected}" rerender="table" onclick="window.top.close()" oncomplete="javascript&colon;closeRefresh('{!Opportunity.Id}');"/>
                       </apex:pageBlockButtons>
                    </apex:pageBlock>
                 </td>
            </tr>
         </table>
            <apex:pageBlock title="Debug - SOQL" id="debug">
               <apex:outputText value="{!debugSoql}" />           
            </apex:pageBlock>    
      </apex:pageBlock>
   </apex:form>
</apex:page>

 Any help would be appriciated.

 

Thanks.

Hi all,

 

I created a VF page that will allow reps to lookup a custom object called Pricing from another custom object called Products.

 

Everything works, I just need to be able to either auto populate the return value of the Terms field based on a range of numbers gathered from the Terms field input, or create a picklist from the text field.

 

1. Term lookup

a. This field is a text field.

b. the values can range from 1 to 60

1. Can I write code that will read - If the value in the field is less than or equal to 12, return the pricing information that has the Term            value of 12.  If the value in the field is greater than 12 but less than 24, return 24.  Etc.?

2. Term picklist - Can I create a picklist value that they select in the Term field that will only return pricing information that has the    Term value of 12, 24, 36, 48, 60?  Even though the Term field on the Products object is a text field?

 

Here is the Class and VF page.

 

public class PricingSearchController {
 
  // the soql without the order and limit
  private String soql {get;set;}
  
  // the collection of Pricing to display
  public List<AboveNet_Pricing__c> pricings {get;set;}
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by defaults to Product Name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public PricingSearchController() {
    soql = 'select CurrencyIsoCode, Part_Number__c, Product_Family__c, Name, Product_Description__c, Term_months__c, Qty_Mbps__c, List_NRC__c, List_MRC__c, Sales_Discount_MRC__c, Max_Discount_MRC__c, Notes__c from AboveNet_Pricing__c where Product_Family__c != null';
    runQuery();
  }
 
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      pricings = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 100');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
 
    String ProductCurrency = Apexpages.currentPage().getParameters().get('ProductCurrency');
    String ProductFamily = Apexpages.currentPage().getParameters().get('ProductFamily');
    String Name = Apexpages.currentPage().getParameters().get('Name');
    String ProductDescription = Apexpages.currentPage().getParameters().get('ProductDescription');
    String PartNumber = Apexpages.currentPage().getParameters().get('PartNumber');
    String Term = Apexpages.currentPage().getParameters().get('Term');
 
    soql = 'select CurrencyIsoCode, Part_Number__c, Product_Family__c, Name, Product_Description__c, Term_months__c, Qty_Mbps__c, List_NRC__c, List_MRC__c, Sales_Discount_MRC__c, Max_Discount_MRC__c, Notes__c from AboveNet_Pricing__c where Product_Family__c != null';
    if (!ProductCurrency.equals(''))
      //soql += ' and CurrencyIsoCode includes (\''+ProductCurrency+'\')';
      soql += ' and CurrencyIsoCode LIKE \''+String.escapeSingleQuotes(ProductCurrency)+'%\'';
    if (!ProductFamily.equals(''))
      soql += ' and Product_Family__c LIKE \''+String.escapeSingleQuotes(ProductFamily)+'%\'';
    if (!Name.equals(''))
      soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
    if (!ProductDescription.equals(''))
      soql += ' and Product_Description__c LIKE \''+String.escapeSingleQuotes(ProductDescription)+'%\''; 
    if (!Term.equals(''))
      soql += ' and Term_months__c LIKE \''+String.escapeSingleQuotes(Term)+'%\'';
    if (!PartNumber.equals(''))
      soql += ' and Part_Number__c LIKE \''+String.escapeSingleQuotes(PartNumber)+'%\''; 
 
    // run the query again
    runQuery();
 
    return null;
  }
 
  // use apex describe to build the picklist values
  public List<String> ProductCurrencies {
    get {
      if (ProductCurrencies == null) {
 
        ProductCurrencies = new List<String>();
        Schema.DescribeFieldResult field = AboveNet_Pricing__c.CurrencyIsoCode.getDescribe();
 
        for (Schema.PicklistEntry f : field.getPicklistValues())
          ProductCurrencies.add(f.getvalue());
 
      }
      return ProductCurrencies;          
    }
    set;
  }
 
}

 

<apex:page controller="PricingSearchController" sidebar="false">
 
   <apex:form >
      <apex:pageMessages id="errors" />
 
      <apex:pageBlock title="AboveNet Pricing Lookup" mode="edit">
         <table width="100%" border="0">
            <tr>  
               <td width="200" valign="top">
                  <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                  
                     <script type="text/javascript">
                        function doSearch() {
                        searchServer(
                        document.getElementById("ProductCurrency").options[document.getElementById("ProductCurrency").selectedIndex].value,
                        document.getElementById("ProductFamily").value,
                        document.getElementById("Name").value,
                        document.getElementById("ProductDescription").value,
                        document.getElementById("Term").value,
                        document.getElementById("PartNumber").value);
                        } 
                     </script> 
 
                     <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                        <apex:param name="ProductCurrency" value="" />
                        <apex:param name="ProductFamily" value="" />
                        <apex:param name="Name" value="" />
                        <apex:param name="ProductDescription" value="" />
                        <apex:param name="Term" value="" />
                        <apex:param name="PartNumber" value="" />
                     </apex:actionFunction>
 
                     <table cellpadding="2" cellspacing="2">
                        <tr>
                           <td style="font-weight:bold;">Product Currency<br/>
                              <select id="ProductCurrency" onchange="doSearch();">
                                 <option value=""></option>
                                 <apex:repeat value="{!ProductCurrencies}" var="prcs">
                                    <option value="{!prcs}">{!prcs}</option>
                                 </apex:repeat>
                              </select>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Product Family<br/>
                              <input type="text" id="ProductFamily" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Product Name<br/>
                              <input type="text" id="Name" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Product Description<br/>
                              <input type="text" id="ProductDescription" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Term<br/>
                              <input type="text" id="Term" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Part Number<br/>
                              <input type="text" id="PartNumber" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                     </table>
                  </apex:pageBlock>
               </td>
               
                 <td valign="top">
                 
                    <apex:pageBlock mode="edit" id="results">
                     
                       <!-- In our table we are displaying the pPricing records -->
                       <apex:pageBlockTable value="{!pricings}" var="p">
                      
                            <apex:column value="{!p.Part_Number__c}" />
                            <apex:column value="{!p.Product_Family__c}" />
                            <apex:column value="{!p.Name}" />
                            <apex:column value="{!p.Product_Description__c}" />
                            <apex:column value="{!p.Term_months__c}" />
                            <apex:column value="{!p.Qty_Mbps__c}" />
                            <apex:column value="{!p.List_NRC__c}" />
                            <apex:column value="{!p.List_MRC__c}" />
                            <apex:column value="{!p.Sales_Discount_MRC__c}" />
                            <apex:column value="{!p.Max_Discount_MRC__c}" />
                            <apex:column value="{!p.Notes__c}" />
                       </apex:pageBlockTable>
                    </apex:pageBlock>
                 </td>
            </tr>
         </table>
            <apex:pageBlock title="Debug - SOQL" id="debug">
               <apex:outputText value="{!debugSoql}" />           
            </apex:pageBlock>    
      </apex:pageBlock>
   </apex:form>
</apex:page>

 

Thank you for any help in advance.

 

Hi all,

 

I have been trying to map a picklist value from our company website to a custom lookup field on the Leads object.  We have successfully mapped a campaign value from our website to the Campaign lookup field on the Leads object, but we can't seem to get this to work.

 

Here is the successful Campgin map: '70130000000fbri' AS 'Campaign_ID',

 

The value that we are trying to pass is: '0013000000u3Yj0AAE'

The custom lookup field is called: Master_Agent__c

The custom lookup field ID is: 'CF00N30000007ZIUmj_id0_j_id2'

 

Can anyone give me some guidence on this one.  I know this can be done, but I cannot figure out how to pass it to a custom lookup field.

 

Thanks,

Alex

 

Hi all,

 

So I am trying to create a Trigger that will pull the Opportunity Owner's Quota for the month that the Opportunity closes in and then populate a custom field called Owner_Quota__c on the Opportunity.

 

I have been trying to run a query on the Revenue Forecast object that pulls the Opportunity Owners Quota if the following conditions are met:

 

RevenueForecast = rf

Opportunity = o

 

rf.OwnerId = o.OwnerId

// I need to limit the Quota to the month that the Opp closes in

MONTH(rf.StartDate) = MONTH(o.CloseDate)

// I need to limit the Quota to the year that the Opp closes in

YEAR(rf.StarteDate) = YEAR(o.CloseDate)

 

I would include more code, but I can't even save my trigger because I have so many different ways that I am trying to do this.

 

Any help would be appreciated since I can't find very much info on the Revenue Forecast object pertaining to triggers.  Let me know if you need to more info.

 

Thanks,

Alex

 

Hi all,

 

I created a custom object called Lead Contact.  It is located on the Lead Object.  When we have multiple Leads from the same company, we add the extra Leads to the Lead Contact object.  Once the Parent Lead is converted, all Lead Contacts need to be converted to Contacts and assigned to the Parent Account.

 

We also have a custom object called Locations that will be moved over upon conversion of the Lead.

 

The trigger works great in the Sandbox, but I cannot get over 65% coverage in production.  Any suggestions?

 

Trigger:

 

trigger LeadContactConvertAcc on Account (after insert, after update) {

    Account a = [select Id, Lead_Convert_Id__c from Account where Id = :Trigger.new[0].Id limit 1];

    if(a.Lead_Convert_ID__c != NULL) {
      
    Lead l = [select Id from Lead where Id = :a.Lead_Convert_Id__c Limit 1];
        
            for (Lead_Contact__c lc : [Select id, Converted_Account_ID_del__c, First_Name__c,
                   Last_Name__c,Title__c,Email__c,Secondary_Email__c,Phone__c,Fax__c,
                   Mobile__c,Mailing_Street__c,Mailing_City__c,Mailing_State__c,
                   Mailing_Zip__c,Mailing_Country__c 
                   FROM Lead_Contact__c 
                   WHERE Parent_Lead_ID_del__c = :a.Lead_Convert_Id__c]) 
                   
                   {
                           
                   Contact newContact = new Contact (
                     AccountId = a.Id,
                     FirstName = lc.First_Name__c,
                     LastName = lc.Last_Name__c,
                     Title = lc.Title__c,
                     Email = lc.Email__c,
                     Secondary_Email__c = lc.Secondary_Email__c,
                     Phone = lc.Phone__c,
                     Fax = lc.Fax__c,
                     MobilePhone = lc.Mobile__c,
                     MailingStreet = lc.Mailing_Street__c,
                     MailingCity = lc.Mailing_City__c,
                     MailingState = lc.Mailing_State__c,
                     MailingPostalCode = lc.Mailing_Zip__c,
                     MailingCountry = lc.Mailing_Country__c);
                     
                   insert newContact;  
                   
                   lc.Parent_Name_del__c = null;
                   
                   update lc;
     
                   }   
                   
            for (Location__c ln : [select Id, Lead__c, Account__c 
                from Location__c 
                WHERE Lead__c = :a.Lead_Convert_Id__c]) {
                
                ln.Account__c = a.Id;
                
                update ln;
                
     }        
   }
  }

  Class:

 

 

public class LeadContactConvert {

static testMethod void LeadContactConvert() {

Id a1Id;
Id l1Id;
Id lnId;
Id lcId;
Id c1Id;
Id c2Id;

    // CREATE LEAD
    Lead l1 = new Lead();
    
        l1.Lastname='leaddata';
        l1.Company='nav';
        l1.Leadsource='Calling Campaign';
        l1.IsConverted = false;
        l1.IsUnreadByOwner = true;
        l1.Status = 'qualified';
        
        Database.insert(l1);
        l1Id = l1.id;
       

    //CREATE LEAD CONTACT
    Lead_Contact__c lc = new Lead_Contact__c ();
      
        lc.First_Name__c = 'test';
        lc.Last_Name__c = 'test';
        lc.Title__c = 'test';
        lc.Email__c = 'test@test.com';
        lc.secondary_Email__c = 'test2@aol.com';
        lc.Phone__c = '1111111111';
        lc.fax__c = '2222222222';
        lc.Mobile__c = '3333333333';
        lc.Mailing_Street__c = '123 Main St';
        lc.Mailing_City__c = 'Phoenix';
        lc.Mailing_State__c = 'AZ';
        lc.Mailing_Zip__c = '85083';
        lc.Mailing_Country__c = 'USA';
        lc.Parent_Name_del__c = l1.Id;
       
       
       Database.insert(lc);         
       lcId = lc.id;
   
    //CREATE LOCATION
    Location__c  ln = New Location__c ();
      
      ln.Street__c = '123 test';
      ln.City__c = 'Test';
      ln.State__c = 'az';
      ln.zip__c = '11111';
      ln.Entrances_Required__c = 'test';
      ln.Location__c = 1;
      ln.Proposed_Demarc__c = 'test';
      ln.Account__c = NULL;
      ln.Lead__c = l1.Id;
          
      Database.insert(ln);
      lnId = ln.id;
       
    //CREATE ACCOUNT   
    Account a1 = new Account();
        a1.name = 'AName';
        a1.type = 'Prospect';
        a1.Lead_Convert_ID__c = l1.Id;
        
        Database.insert(a1);
        a1Id = a1.Id;
    
     //CREATE CONTACT 1
     Contact c1 = new Contact ();
      
       c1.LastName = l1.Lastname;
       c1.Email = 'test@aol.com';
       c1.Phone = '9999999999';
       c1.AccountId = a1.id;
       
       Database.insert(c1);            
       c1Id = c1.id; 
    
    
    //CREATE CONTACT 2
    Contact c2 = new Contact ();
      
        c2.FirstName = lc.First_Name__c;
        c2.LastName = lc.Last_Name__c;
        c2.Title = lc.Title__c;
        c2.Email = lc.Email__c;
        c2.Secondary_Email__c = lc.Secondary_Email__c;
        c2.Phone = lc.Phone__c;
        c2.Fax = lc.Fax__c;
        c2.MobilePhone = lc.Mobile__c;
        c2.MailingStreet = lc.Mailing_Street__c;
        c2.MailingCity = lc.Mailing_City__c;
        c2.MailingState = lc.Mailing_State__c;
        c2.MailingPostalCode = lc.Mailing_Zip__c;
        c2.MailingCountry = lc.Mailing_Country__c;
        c2.AccountId = lc.Converted_Account_ID_del__c;
       
       Database.insert(c2);            
       c2Id = c2.id;     
     
               
// Account a = [select Id, Lead_Convert_Id__c from Account where Lead_Convert_Id__c = :l1.Id limit 1];
      
//      Lead_Contact__c lc1 = [Select id, Converted_Account_ID_del__c, First_Name__c,
//                   Last_Name__c,Title__c,Email__c,Secondary_Email__c,Phone__c,Fax__c,
//                   Mobile__c,Mailing_Street__c,Mailing_City__c,Mailing_State__c,
//                   Mailing_Zip__c,Mailing_Country__c 
//                   FROM Lead_Contact__c 
//                   WHERE Parent_Name_del__c = :a.Lead_Convert_Id__c]; 
      
      Contact newContact = new Contact (
      AccountId = a1.Id,
      FirstName = lc.First_Name__c,
      LastName = lc.Last_Name__c,
      Title = lc.Title__c,
      Email = lc.Email__c,
      Phone = lc.Phone__c,
      Fax = lc.Fax__c,
      MobilePhone = lc.Mobile__c,
      MailingStreet = lc.Mailing_Street__c,
      MailingCity = lc.Mailing_City__c,
      MailingState = lc.Mailing_State__c,
      MailingPostalCode = lc.Mailing_Zip__c,
      MailingCountry = lc.Mailing_Country__c);
       
      insert newContact; 
        
      lc.Parent_Name_del__c = null;
       
        update lc; 
        
      ln.Account__c = a1.Id;
      
        update ln;  
        
     }
   
}

 

 

Thank you in advance for any assistance.

 

Levi

 

Hi all,

 

Is it possible to reference a rollup field from the Opportunity Object while on the Campaign Object?

 

I created a VF page using APEX on the Campaign object and I would like to Rollup the values from an Opportunity Field for all of the Campaign Opportunities.

 

The field is a rollup field called Total Value of Won Contract on the Opportunity.  It takes the Term x Amount for won Opportunties.

 

The Campaign field would be called "Campaign TVC".

 

Thanks,

Alex

  • September 30, 2010
  • Like
  • 0

Hi all,

 

I am new to Visual Force and trying to create my first page!  I created a Class & VF page on the Campaign Object.  What I am trying to do is pull all of the Leads that are associated to the Campaign that have been Disqualified.

 

If I use html, I can display the data on the VF page just fine, but I would like to use APEX instead.

 

Here is the Class:

 

 

public with sharing class CampaignMetricsRL {

    public CampaignMetricsRL(ApexPages.StandardController controller) {

    }


public PageReference ViewData() {

return null;
}
 
List<Campaign> rqs;

Id cid = ApexPages.currentPage().getParameters().get('id');

 public List<Campaign> getCampaign() {

  if(rqs == null){
  rqs = [select Id, Name, Actual_Cost__c, NumberOfLeads, NumberOfContacts, NumberOfOpportunities,
         NumberOfWonOpportunities, AmountWonOpportunities, OwnerId, CreatedDate
         from Campaign
         limit 1];
  }
  return  rqs;
 }


public Integer getDQLeads() {

return [

select count() from CampaignMember

where Lead.Lead_is_Disqualified__c = True AND Campaignid = :cid
      
];

} 
}

 

Here is the Visual Force Page:

 

 

<apex:page standardController="Campaign" extensions="CampaignMetricsRL" showHeader="false">


<apex:form id="test">
  <apex:pageblock title="">

      <tr>     
           
        <apex:pageBlockTable value="{!Campaign}" var="C" id="table">
                                                     

           <apex:column >                      
              
                 <table>
 
 <tr><td align="center"></td></tr>                 
 <tr><td align="center"></td></tr>
 <tr><td align="center"><u><font size="4" color="#000000">Leads</font></u></td></tr>
 <tr><td align="center"><font size="3" color="#000000"><b>{!C.NumberOfLeads}</b></font></td></tr>                
                    
                 </table>       
            
           </apex:column> 
   
        
           <apex:column >                      
              
                 <table>

 <tr><td align="center"><u><font size="4" color="#000000">Disqualified Leads</font></u></td></tr>
 <tr><td align="center"><font size="3" color="#000000"><b>{!DQLeads}</b></font></td></tr>                
                    
                 </table>       
            
           </apex:column>
         

    
      
                
  </apex:pageblock>
    
</apex:form>


</apex:page>

 I would love to use APEX over HTML.  Any help would be appreciated!

 

Thanks,

Alex

 

 

  • September 15, 2010
  • Like
  • 0

Hi all,

 

I am trying to move a Trigger into Production but I am getting a 0% coverage when I validate it through Eclipse/Force.com.  I have 100% coverage when I run all tests in the sandbox.

 

The trigger will move the owner of an event to match the new lead owner once the lead is moved from a lead queue owner.

 

Here is the trigger and class.  I already received help from the discussion board on the trigger, thanks again in advance.

 

Any suggestions?

 

 

**** Trigger ****

trigger ownerupdate on Lead (after Update) {

List<Event> aplist = new List<Event>();

for(Lead t : Trigger.new){

IF(
(t.LeadSource == 'Telemarketing'
    && t.OwnerId != '00G30000001iNeKEAU' 
     && t.OwnerId != '00G30000001iNtxEAE'
      && t.OwnerId != '00G30000001uiO5'
       && t.OwnerId != '00G30000001iCwM'
        && t.OwnerId != '00G30000001uh70'
         && t.OwnerId != '00G30000001iNt5EAE'
          && t.OwnerId != '00G30000001ui8wEAA'
           && t.OwnerId != '00G30000001iNuC'
            && t.OwnerId != '00G30000001iNsL'
             && t.OwnerId != '00G30000001iNvZ'
              && t.OwnerId != '00G30000001jtEi'
               && t.OwnerId != '00G30000001tiXR'
                && t.OwnerId != '00G30000001ui8w'
                 && t.OwnerId != '00G30000001iNt5'
))

{List<Event> aps = [Select WhoId, Whatid, OwnerId from Event where WhoId = :t.Id];
   for (Event ap : aps)
   {       
      ap.OwnerId = t.OwnerId;

      aplist.add( ap );
   }

}}
update aplist;
}
trigger ownerupdate on Lead (after Update) {
    && t.OwnerId != '00G30000001iNeKEAU' 
**** Class Test Method **** public class ownerupdate { static testMethod void T1() { Id lId; Id eId; //CREATE 1 LEAD Lead l = new Lead(); l.LeadSource = 'Telemarketing'; l.lastname = 'Doe'; l.company = 'Test Company'; l.ownerId = '00530000003IFwV'; l.status = 'Open'; l.market__c = 'Atlanta'; Database.insert(l); lId = l.Id; //CREATE 2 Event Event e = New Event (); e.DurationInMinutes = 60; e.ActivityDateTime = date.today(); e.ownerId = l.ownerId; e.WhoId = l.Id; Database.SaveResult result = Database.insert(e); eId = e.Id; update e; {List<Lead> aps = [Select Leadsource, owner_convert_queue__c, id, OwnerId from Lead where id = :e.whoId]; system.debug('@@@apo=' + aps); } }}

 

Alex

 

  • September 01, 2010
  • Like
  • 0

Hi all,

 

I created a trigger that will update the Event owner to the owner of the Lead whenever the Lead owner is changed.  We have a process where we assign a Lead to a queue with a scheduled appointment(Event) already assigned to an admin.  

 

The trigger will only fire if the Lead owner does not equal a "Queue" owner.

 

I am getting an error when:

 

 

  1. There is more than one Event on the Lead
  2. If there are no Events on the Lead
trigger ownerupdate on Lead (after Update) {

List<Event> aplist = new List<Event>();

for(Lead t : Trigger.new){

if (
(t.LeadSource == 'Telemarketing')  
&&
(t.Owner_Convert_Queue__c == NULL)
)

{Event ap = [Select WhoId, Whatid, OwnerId from Event where WhoId = :t.Id];

            
ap.OwnerId = t.OwnerId;

aplist.add( ap );

}}
update aplist;
}

 

Any help would be appreciated.

 

Thanks,

Alex

 

Hi all,

 

We have two custom objects:

 

1. Locations

2. Address Data

 

The Location object has a lookup field where you select the street address from the Address Data object.  Once you hit save, the address info is auto populated to the Location object via a workflow.  This works great.

 

The problem that I am having is one of the fields on the Location object is called "Market".  This is a formula field that is populated based on either the State, ZIP or Country.  I need to simplify this code/fix it because it is returning errors when the Country field is referenced.

 

Here is the code:

 

IF(State__c="MA" || State__c="RI" , "Boston", 
IF(State__c="CT" || State__c="NY" || State__c="NJ" ,"NY/NJ", 
IF(State__c="PA" , "Philadelphia", 
IF(State__c="MD" , "Baltimore", 
IF(State__c="VA" || State__c="DC", "WDC/VA", 
IF(State__c="GA" , "Atlanta", 
IF(State__c="IL" , "Chicago", 
IF((VALUE(Zip__c)) >= 75001 && (VALUE(Zip__c)) <= 76487 , "Dallas", 
IF((VALUE(Zip__c)) >= 73301 && (VALUE(Zip__c)) <= 73344 , "Austin", 
IF((VALUE(Zip__c)) >= 78602 && (VALUE(Zip__c)) <= 78957 , "Austin", 
IF((VALUE(Zip__c)) >= 77001 && (VALUE(Zip__c)) <= 77598 , "Houston", 
IF(State__c="AZ" , "Phoenix", 
IF((VALUE(Zip__c)) >= 90001 && (VALUE(Zip__c)) <= 93599, "Los Angeles", 
IF((VALUE(Zip__c)) >= 94001 && (VALUE(Zip__c)) <= 95487 , "SF Bay Area", 
IF(State__c="OR" , "Portland",
IF(State__c="FL", "Miami", 
IF(State__c="CO", "Denver",
IF(Country__c="United Kingdom", "London",
IF(Country__c="Germany", "Frankfurt",
IF(Country__c="France", "Paris",
IF(Country__c="Netherlands", "Amsterdam",
IF(State__c="WA" , "Seattle", "Other"
))))))))))))))))))))))

 

Any suggestions would be greatly appreciated.

 

Thanks,

Alex

 

 

Hi all,

 

I need to create a trigger on the Task object that changes the "Related To" field from a custom object (ABC Products) to the Opportunity associated to the custom object on creation.

 

Three object are being referenced:

1. Task

2. Opportunity

3. ABC Products (custom object)

 

The following Trigger does what I need it to do, but it is also effecting ALL Tasks, not just the ones that meet the criteria. 

 

Can someone help me out here and explain how to limit the trigger to just the qualified Tasks?

 

Here is what I have so far:

 

 

trigger taskupdate on Task (before insert, before update) { List<ABC_Product__c> ablist = new List<ABC_Product__c>(); for(Task t: Trigger.new){ ABC_Product__c ab = [Select id, Opportunity_Name__c from ABC_Product__c where id = :t.WhatId]; t.WhatId = ab.Opportunity_Name__c; ablist.add( ab ); } update ablist; }

 

Any help would be appreciated.

 

Thanks,

Alex

 

Hi all,

 

I am trying to create a formula, but it is not working for the problem that I have.  I am just starting to learn about triggers and need some help with one.

 

The fields called "Forecast Category" and "Stage" on the Opportunity page, are the two fields I am using.

 

I am trying to override the auto update of the Forecast Category when I change the Opportunity stage.

 

Forecast Field = Committed

Stage = Proposal

 

If the Stage is changed from Proposal to Contract, the system auto updates the Forecast to "Upside". 

 

On Save = I would like for the Forecast to stay as "Committed", but only if the prior Stage was "Proposal" and the Forecast was "Committed".

 

 

I hope that makes sense.  Any help would be greatly appreciated!

 

Thanks,

Alex

 

 

Hi all,

 

Is there a way to have a field that will automatically create a number  for each Address that I create within an Account?

 

  1. I created an Object called Location - Were we store all of our address (Billing, Shipping, Servie and Corporate)
  2. I created an Auto Number field called Location #.
  3. This field needs to auto populate with a number upon creation for reporting purposes.
  4. This number needs to be unique by Account.
  5. Currently when I create an address it numbers correctly within the first Account: 1,2,3,etc. - but when I go to another Account, it continues the numbering cycle: 4,5,6, etc.
Any suggestions?
  • September 24, 2009
  • Like
  • 0

Hi all,

 

I am hoping someone can help me out with a formula that I am trying to create.  I am looking to capture all of the Opportunities that are in a Stage called Proposal that are associated with a certain Campaign.  I am looking for two seperate fields:

 

1. The results need to be in a numerical format, similar to the standard campaign field called Num Total Opportunites. 

2.  The results need to be in a currency format, similar to the standard campaign field called Total Value Opportunities.

 

I am new to formulas and I have been researching for a while.  Any suggestions would be great.

 

Thank you!

Levi

 

  • September 18, 2009
  • Like
  • 0

Hi all,

 

We are looking to hire a temporary developer to write classes & triggers for our Salesforce.com and Oracle EBS11 integration. The model is already in place, but we do need some extra help.

 

Looking find someone within the next few months.


Please let me know. 

Thanks, 
Alex Searcy 

Hi all,

 

I created an object called Locations that pulls data from another custom object called FNL.  I created a button on the Opportunity object that will allow a rep to lookup a given FNL location and create a Location item.  I currently have the following features working: The FNL search fields, the matching values based on the search and the existing Locations that are already associated to the Opportunity.

 

What I am having trouble with is being able to create checkboxes next to the matching values that are returned that will allow me to add them to the Opportunity.

 

public class LocationSearchController {

 public PageReference Cancel() {
        return null;
    }

        public Opportunity o { get; set; }
    Id myid= ApexPages.currentPage().getParameters().get('id');
    
    public PageReference ViewData() {

    return null;
    }
     
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of FNL to display
  public List<FNL__c> fnl {get;set;}
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by. defaults to Name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public LocationSearchController() {
    soql = 'select Name, FNL_Suite__c, FNL_City__c, FNL_State__c, FNL_Zip__c, Building_Code__c from FNL__c where Name != null';
    runQuery();
   
    o = [select Id, Name, OwnerId, Account.Name, RecordType.Name, Existing_Order_Number__c, AboveNet_Order_Number__c, Quote_MRC_Total__c, 
                 Quote_NRC_Total__c, TechChange__c, Commencement_Date__c, PrepaymentAmount__c, ImplementationComments__c, BillingComments__c 
                 from Opportunity 
                 where id = :myid];     
  }
  
  public Opportunity getOpportunity() {
            return o;
  }
 
 
    //Our collection of the class/wrapper objects cLoctact 
    public List<cLocation> locationList {get; set;}

    //This method uses a simple SOQL query to return a List of Contacts
    public List<cLocation> getLocations() {
        if(locationList == null) {
            locationList = new List<cLocation>();
            for(Location__c c : [select Id, Street__c, City__c, State__c, zip__c, Entrances_Required__c, Location__c, Proposed_Demarc__c,
                            Country__c, FNL_Building_Code__c, Location_Type__c, Available_Entrance__c, Building_Fiber_Demarc__c, Name, 
                            Building_is_OnNet__c, Building_Type__c, Suite__c, FNL_Street__c from Location__c where Account__c = :o.AccountId]) {
                // As each contact is processed we create a new cLoctact object and add it to the contactList
                locationList.add(new cLocation(c));
            }
        }
        return locationList;
    }
   
     public PageReference processSelected() {

        //We create a new list of Locations that we be populated only with FNL if they are selected
        List<Location__c> selectedLocations = new List<Location__c>();

        //We will cycle through our list of cLocations and will check to see if the selected property is set to true, if it is we add the FNL to the selectedLocations list
        for(cLocation cLoc : getLocations()) {
            if(cLoc.selected == true) {
                selectedLocations.add(cLoc.loc);
            }
        }

        // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
        List <Location__c> newloc = new List<Location__c>();

        for(Location__c loc : selectedLocations) {
            
            Location__c nloc; 
            nloc = loc.clone(false);
            nloc.Opportunity__c = o.Id;
            nloc.Account__c = null;
            
            newloc.add(nloc);
        }
        
        insert newloc;
        return null;
    }

//Our collection of the class/wrapper objects cLocations 
    public List<dfnl> fnlList {get; set;}

    //This method uses a simple SOQL query to return a List of FNL
    public List<dfnl> getfnl() {
        if(fnlList == null) {
            fnlList = new List<dfnl>();
               for(FNL__c d : Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20') ) 
            {
                // As each contact is processed we create a new cFNL object and add it to the Location List
                fnlList.add(new dfnl(d));
             }
        }
        return fnlList;
    }
   
     public PageReference processSelectedf() {

        //We create a new list of Contacts that we be populated only with Contacts if they are selected
        List<FNL__c> selectedfnl = new List<FNL__c>();

        //We will cycle through our list of cLoctacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedLocations list
        for(dfnl dF : getfnl()) {
            if(dF.selected == true) {
                selectedfnl.add(dF.fnl2);
            }
        }

        // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
        List <Location__c> newloc1 = new List<Location__c>();

        for(FNL__c fnl : selectedfnl) {
            
            Location__c nloc1;
            nloc1.Access_Type__c = fnl.Access_Type__c;
            nloc1.Assets__c = fnl.Assets__c;
            nloc1.FNL_Building_Code__c = fnl.Building_Code__c;
            nloc1.Building_Fiber_Demarc__c = fnl.Building_Fiber_Demarc__c;
            nloc1.Building_Type__c = fnl.Building_Type__c;
            nloc1.Datacenter__c = fnl.Datacenter__c;
            nloc1.Entrances_Required__c = fnl.Entrance__c;
            nloc1.Street__c = fnl.FNL_Street__c;
            nloc1.Suite__c = fnl.FNL_Suite__c;
            nloc1.City__c = fnl.FNL_City__c;
            nloc1.State__c = fnl.FNL_State__c;
            nloc1.Zip__c = fnl.FNL_Zip__c;
            nloc1.Country__c = fnl.FNL_Country__c;
            nloc1.IP_POP__c = fnl.IP_POP__c;
            nloc1.IP_VPOP__c = fnl.IP_VPOP__c;
            nloc1.LH_POP__c = fnl.LH_POP__c;
            nloc1.LH_VPOP__c = fnl.LH_VPOP__c;
            nloc1.Opportunity__c = o.Id;
            nloc1.Account__c = null;
            
            newloc1.add(nloc1);
        }
        
        insert newloc1;
        return null;
    }


    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class cLocation {
        public Location__c loc {get; set;}
        public Boolean selected {get; set;}

        //This is the contructor method. When we create a new cLoctact object we pass a Contact that is set to the con property. We also set the selected value to false
        public cLocation(Location__c c) {
            loc = c;
            selected = false;
         }
    }
     
      // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class dFNL {
        public FNL__c fnl2 {get; set;}
        public Boolean selected {get; set;}

     //This is the contructor method. When we create a new cLoctact object we pass a Contact that is set to the con property. We also set the selected value to false
        public dFNL(FNL__c d) {
            fnl2 = d;
            selected = false;
         }
    }
  
     
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      fnl = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
 
    String Name = Apexpages.currentPage().getParameters().get('Name');
    String fnlcity= Apexpages.currentPage().getParameters().get('fnlcity');
    String buildingcode= Apexpages.currentPage().getParameters().get('buildingcode');
 
    soql = 'select Name, FNL_Suite__c, FNL_City__c, FNL_State__c, FNL_Zip__c, Building_Code__c from FNL__c where Name != null';
    if (!Name.equals(''))
      soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
    if (!fnlcity.equals(''))
      soql += ' and FNL_City__c LIKE \''+String.escapeSingleQuotes(fnlcity)+'%\'';
    if (!buildingcode.equals(''))
      soql += ' and Building_Code__c LIKE \''+String.escapeSingleQuotes(buildingcode)+'%\''; 
 
    // run the query again
    runQuery();

    return null;
  }
 

}

 

<apex:page controller="LocationSearchController" sidebar="false">
 
   <apex:form >
      <apex:pageBlock >
         <apex:pageBlockButtons >
            <apex:commandButton value="Add Selected Location to Opportunity" action="{!processSelected}" rerender="table" onclick="window.top.close()" oncomplete="javascript&colon;closeRefresh('{!Opportunity.Id}');"/>
            <apex:commandButton value="Cancel" action="{!Cancel}" rerender="table" onclick="window.top.close();"/>
         </apex:pageBlockButtons>
         <!-- In our table we are displaying the cContact records -->
         <apex:pageBlockTable value="{!locations}" var="c" id="table">
            <apex:column >
            <!-- This is our selected Boolean property in our wrapper class -->
             <apex:inputCheckbox value="{!c.selected}"/>
            </apex:column>
                <!-- This is how we access the contact values within our cContact container/wrapper -->
                   <apex:column value="{!c.loc.Name}" />
                   <apex:column value="{!c.loc.Street__c}" />
                   <apex:column value="{!c.loc.City__c}" />
                   <apex:column value="{!c.loc.State__c}" />
         </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
    
   <apex:form >
      <apex:pageMessages id="errors" />
 
      <apex:pageBlock title="FNL Lookup" mode="edit">
         <table width="100%" border="0">
            <tr>  
               <td width="200" valign="top">
                  <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                     <script type="text/javascript">
                        function doSearch() {
                        searchServer(
                        document.getElementById("Name").value,
                        document.getElementById("fnlcity").value,
                        document.getElementById("buildingcode").value);
                        } 
                     </script> 
 
                     <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                        <apex:param name="Name" value="" />
                        <apex:param name="fnlcity" value="" />
                        <apex:param name="buildingcode" value="" />
                     </apex:actionFunction>
 
                     <table cellpadding="2" cellspacing="2">
                        <tr>
                           <td style="font-weight:bold;">Street<br/>
                              <input type="text" id="Name" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">City<br/>
                              <input type="text" id="fnlcity" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Building Code<br/>
                              <input type="text" id="buildingcode" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                     </table>
                  </apex:pageBlock>
               </td>
                 <td valign="top">
                    <apex:pageBlock mode="edit" id="results">
                    <!-- In our table we are displaying the cContact records -->
                       <apex:pageBlockTable value="{!fnl}" var="d" id="FNLtable">

                            <apex:column value="{!d.Name}" />
                            <apex:column value="{!d.FNL_Suite__c}" />
                            <apex:column value="{!d.FNL_City__c}" />
                            <apex:column value="{!d.FNL_State__c}" />
                            <apex:column value="{!d.FNL_Zip__c}" />
                            <apex:column value="{!d.Building_Code__c}" />
                       </apex:pageBlockTable>
                       <apex:pageBlockButtons >
                          <apex:commandButton value="Add Selected Location to Opportunity" action="{!processSelected}" rerender="table" onclick="window.top.close()" oncomplete="javascript&colon;closeRefresh('{!Opportunity.Id}');"/>
                       </apex:pageBlockButtons>
                    </apex:pageBlock>
                 </td>
            </tr>
         </table>
            <apex:pageBlock title="Debug - SOQL" id="debug">
               <apex:outputText value="{!debugSoql}" />           
            </apex:pageBlock>    
      </apex:pageBlock>
   </apex:form>
</apex:page>

 Any help would be appriciated.

 

Thanks.

Hi all,

 

I created a VF page that will allow reps to lookup a custom object called Pricing from another custom object called Products.

 

Everything works, I just need to be able to either auto populate the return value of the Terms field based on a range of numbers gathered from the Terms field input, or create a picklist from the text field.

 

1. Term lookup

a. This field is a text field.

b. the values can range from 1 to 60

1. Can I write code that will read - If the value in the field is less than or equal to 12, return the pricing information that has the Term            value of 12.  If the value in the field is greater than 12 but less than 24, return 24.  Etc.?

2. Term picklist - Can I create a picklist value that they select in the Term field that will only return pricing information that has the    Term value of 12, 24, 36, 48, 60?  Even though the Term field on the Products object is a text field?

 

Here is the Class and VF page.

 

public class PricingSearchController {
 
  // the soql without the order and limit
  private String soql {get;set;}
  
  // the collection of Pricing to display
  public List<AboveNet_Pricing__c> pricings {get;set;}
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by defaults to Product Name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public PricingSearchController() {
    soql = 'select CurrencyIsoCode, Part_Number__c, Product_Family__c, Name, Product_Description__c, Term_months__c, Qty_Mbps__c, List_NRC__c, List_MRC__c, Sales_Discount_MRC__c, Max_Discount_MRC__c, Notes__c from AboveNet_Pricing__c where Product_Family__c != null';
    runQuery();
  }
 
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      pricings = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 100');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
 
    String ProductCurrency = Apexpages.currentPage().getParameters().get('ProductCurrency');
    String ProductFamily = Apexpages.currentPage().getParameters().get('ProductFamily');
    String Name = Apexpages.currentPage().getParameters().get('Name');
    String ProductDescription = Apexpages.currentPage().getParameters().get('ProductDescription');
    String PartNumber = Apexpages.currentPage().getParameters().get('PartNumber');
    String Term = Apexpages.currentPage().getParameters().get('Term');
 
    soql = 'select CurrencyIsoCode, Part_Number__c, Product_Family__c, Name, Product_Description__c, Term_months__c, Qty_Mbps__c, List_NRC__c, List_MRC__c, Sales_Discount_MRC__c, Max_Discount_MRC__c, Notes__c from AboveNet_Pricing__c where Product_Family__c != null';
    if (!ProductCurrency.equals(''))
      //soql += ' and CurrencyIsoCode includes (\''+ProductCurrency+'\')';
      soql += ' and CurrencyIsoCode LIKE \''+String.escapeSingleQuotes(ProductCurrency)+'%\'';
    if (!ProductFamily.equals(''))
      soql += ' and Product_Family__c LIKE \''+String.escapeSingleQuotes(ProductFamily)+'%\'';
    if (!Name.equals(''))
      soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
    if (!ProductDescription.equals(''))
      soql += ' and Product_Description__c LIKE \''+String.escapeSingleQuotes(ProductDescription)+'%\''; 
    if (!Term.equals(''))
      soql += ' and Term_months__c LIKE \''+String.escapeSingleQuotes(Term)+'%\'';
    if (!PartNumber.equals(''))
      soql += ' and Part_Number__c LIKE \''+String.escapeSingleQuotes(PartNumber)+'%\''; 
 
    // run the query again
    runQuery();
 
    return null;
  }
 
  // use apex describe to build the picklist values
  public List<String> ProductCurrencies {
    get {
      if (ProductCurrencies == null) {
 
        ProductCurrencies = new List<String>();
        Schema.DescribeFieldResult field = AboveNet_Pricing__c.CurrencyIsoCode.getDescribe();
 
        for (Schema.PicklistEntry f : field.getPicklistValues())
          ProductCurrencies.add(f.getvalue());
 
      }
      return ProductCurrencies;          
    }
    set;
  }
 
}

 

<apex:page controller="PricingSearchController" sidebar="false">
 
   <apex:form >
      <apex:pageMessages id="errors" />
 
      <apex:pageBlock title="AboveNet Pricing Lookup" mode="edit">
         <table width="100%" border="0">
            <tr>  
               <td width="200" valign="top">
                  <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                  
                     <script type="text/javascript">
                        function doSearch() {
                        searchServer(
                        document.getElementById("ProductCurrency").options[document.getElementById("ProductCurrency").selectedIndex].value,
                        document.getElementById("ProductFamily").value,
                        document.getElementById("Name").value,
                        document.getElementById("ProductDescription").value,
                        document.getElementById("Term").value,
                        document.getElementById("PartNumber").value);
                        } 
                     </script> 
 
                     <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                        <apex:param name="ProductCurrency" value="" />
                        <apex:param name="ProductFamily" value="" />
                        <apex:param name="Name" value="" />
                        <apex:param name="ProductDescription" value="" />
                        <apex:param name="Term" value="" />
                        <apex:param name="PartNumber" value="" />
                     </apex:actionFunction>
 
                     <table cellpadding="2" cellspacing="2">
                        <tr>
                           <td style="font-weight:bold;">Product Currency<br/>
                              <select id="ProductCurrency" onchange="doSearch();">
                                 <option value=""></option>
                                 <apex:repeat value="{!ProductCurrencies}" var="prcs">
                                    <option value="{!prcs}">{!prcs}</option>
                                 </apex:repeat>
                              </select>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Product Family<br/>
                              <input type="text" id="ProductFamily" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Product Name<br/>
                              <input type="text" id="Name" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Product Description<br/>
                              <input type="text" id="ProductDescription" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Term<br/>
                              <input type="text" id="Term" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Part Number<br/>
                              <input type="text" id="PartNumber" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                     </table>
                  </apex:pageBlock>
               </td>
               
                 <td valign="top">
                 
                    <apex:pageBlock mode="edit" id="results">
                     
                       <!-- In our table we are displaying the pPricing records -->
                       <apex:pageBlockTable value="{!pricings}" var="p">
                      
                            <apex:column value="{!p.Part_Number__c}" />
                            <apex:column value="{!p.Product_Family__c}" />
                            <apex:column value="{!p.Name}" />
                            <apex:column value="{!p.Product_Description__c}" />
                            <apex:column value="{!p.Term_months__c}" />
                            <apex:column value="{!p.Qty_Mbps__c}" />
                            <apex:column value="{!p.List_NRC__c}" />
                            <apex:column value="{!p.List_MRC__c}" />
                            <apex:column value="{!p.Sales_Discount_MRC__c}" />
                            <apex:column value="{!p.Max_Discount_MRC__c}" />
                            <apex:column value="{!p.Notes__c}" />
                       </apex:pageBlockTable>
                    </apex:pageBlock>
                 </td>
            </tr>
         </table>
            <apex:pageBlock title="Debug - SOQL" id="debug">
               <apex:outputText value="{!debugSoql}" />           
            </apex:pageBlock>    
      </apex:pageBlock>
   </apex:form>
</apex:page>

 

Thank you for any help in advance.

 

Hi all,

 

I have been trying to map a picklist value from our company website to a custom lookup field on the Leads object.  We have successfully mapped a campaign value from our website to the Campaign lookup field on the Leads object, but we can't seem to get this to work.

 

Here is the successful Campgin map: '70130000000fbri' AS 'Campaign_ID',

 

The value that we are trying to pass is: '0013000000u3Yj0AAE'

The custom lookup field is called: Master_Agent__c

The custom lookup field ID is: 'CF00N30000007ZIUmj_id0_j_id2'

 

Can anyone give me some guidence on this one.  I know this can be done, but I cannot figure out how to pass it to a custom lookup field.

 

Thanks,

Alex

 

Hi all,

 

I created a custom object called Lead Contact.  It is located on the Lead Object.  When we have multiple Leads from the same company, we add the extra Leads to the Lead Contact object.  Once the Parent Lead is converted, all Lead Contacts need to be converted to Contacts and assigned to the Parent Account.

 

We also have a custom object called Locations that will be moved over upon conversion of the Lead.

 

The trigger works great in the Sandbox, but I cannot get over 65% coverage in production.  Any suggestions?

 

Trigger:

 

trigger LeadContactConvertAcc on Account (after insert, after update) {

    Account a = [select Id, Lead_Convert_Id__c from Account where Id = :Trigger.new[0].Id limit 1];

    if(a.Lead_Convert_ID__c != NULL) {
      
    Lead l = [select Id from Lead where Id = :a.Lead_Convert_Id__c Limit 1];
        
            for (Lead_Contact__c lc : [Select id, Converted_Account_ID_del__c, First_Name__c,
                   Last_Name__c,Title__c,Email__c,Secondary_Email__c,Phone__c,Fax__c,
                   Mobile__c,Mailing_Street__c,Mailing_City__c,Mailing_State__c,
                   Mailing_Zip__c,Mailing_Country__c 
                   FROM Lead_Contact__c 
                   WHERE Parent_Lead_ID_del__c = :a.Lead_Convert_Id__c]) 
                   
                   {
                           
                   Contact newContact = new Contact (
                     AccountId = a.Id,
                     FirstName = lc.First_Name__c,
                     LastName = lc.Last_Name__c,
                     Title = lc.Title__c,
                     Email = lc.Email__c,
                     Secondary_Email__c = lc.Secondary_Email__c,
                     Phone = lc.Phone__c,
                     Fax = lc.Fax__c,
                     MobilePhone = lc.Mobile__c,
                     MailingStreet = lc.Mailing_Street__c,
                     MailingCity = lc.Mailing_City__c,
                     MailingState = lc.Mailing_State__c,
                     MailingPostalCode = lc.Mailing_Zip__c,
                     MailingCountry = lc.Mailing_Country__c);
                     
                   insert newContact;  
                   
                   lc.Parent_Name_del__c = null;
                   
                   update lc;
     
                   }   
                   
            for (Location__c ln : [select Id, Lead__c, Account__c 
                from Location__c 
                WHERE Lead__c = :a.Lead_Convert_Id__c]) {
                
                ln.Account__c = a.Id;
                
                update ln;
                
     }        
   }
  }

  Class:

 

 

public class LeadContactConvert {

static testMethod void LeadContactConvert() {

Id a1Id;
Id l1Id;
Id lnId;
Id lcId;
Id c1Id;
Id c2Id;

    // CREATE LEAD
    Lead l1 = new Lead();
    
        l1.Lastname='leaddata';
        l1.Company='nav';
        l1.Leadsource='Calling Campaign';
        l1.IsConverted = false;
        l1.IsUnreadByOwner = true;
        l1.Status = 'qualified';
        
        Database.insert(l1);
        l1Id = l1.id;
       

    //CREATE LEAD CONTACT
    Lead_Contact__c lc = new Lead_Contact__c ();
      
        lc.First_Name__c = 'test';
        lc.Last_Name__c = 'test';
        lc.Title__c = 'test';
        lc.Email__c = 'test@test.com';
        lc.secondary_Email__c = 'test2@aol.com';
        lc.Phone__c = '1111111111';
        lc.fax__c = '2222222222';
        lc.Mobile__c = '3333333333';
        lc.Mailing_Street__c = '123 Main St';
        lc.Mailing_City__c = 'Phoenix';
        lc.Mailing_State__c = 'AZ';
        lc.Mailing_Zip__c = '85083';
        lc.Mailing_Country__c = 'USA';
        lc.Parent_Name_del__c = l1.Id;
       
       
       Database.insert(lc);         
       lcId = lc.id;
   
    //CREATE LOCATION
    Location__c  ln = New Location__c ();
      
      ln.Street__c = '123 test';
      ln.City__c = 'Test';
      ln.State__c = 'az';
      ln.zip__c = '11111';
      ln.Entrances_Required__c = 'test';
      ln.Location__c = 1;
      ln.Proposed_Demarc__c = 'test';
      ln.Account__c = NULL;
      ln.Lead__c = l1.Id;
          
      Database.insert(ln);
      lnId = ln.id;
       
    //CREATE ACCOUNT   
    Account a1 = new Account();
        a1.name = 'AName';
        a1.type = 'Prospect';
        a1.Lead_Convert_ID__c = l1.Id;
        
        Database.insert(a1);
        a1Id = a1.Id;
    
     //CREATE CONTACT 1
     Contact c1 = new Contact ();
      
       c1.LastName = l1.Lastname;
       c1.Email = 'test@aol.com';
       c1.Phone = '9999999999';
       c1.AccountId = a1.id;
       
       Database.insert(c1);            
       c1Id = c1.id; 
    
    
    //CREATE CONTACT 2
    Contact c2 = new Contact ();
      
        c2.FirstName = lc.First_Name__c;
        c2.LastName = lc.Last_Name__c;
        c2.Title = lc.Title__c;
        c2.Email = lc.Email__c;
        c2.Secondary_Email__c = lc.Secondary_Email__c;
        c2.Phone = lc.Phone__c;
        c2.Fax = lc.Fax__c;
        c2.MobilePhone = lc.Mobile__c;
        c2.MailingStreet = lc.Mailing_Street__c;
        c2.MailingCity = lc.Mailing_City__c;
        c2.MailingState = lc.Mailing_State__c;
        c2.MailingPostalCode = lc.Mailing_Zip__c;
        c2.MailingCountry = lc.Mailing_Country__c;
        c2.AccountId = lc.Converted_Account_ID_del__c;
       
       Database.insert(c2);            
       c2Id = c2.id;     
     
               
// Account a = [select Id, Lead_Convert_Id__c from Account where Lead_Convert_Id__c = :l1.Id limit 1];
      
//      Lead_Contact__c lc1 = [Select id, Converted_Account_ID_del__c, First_Name__c,
//                   Last_Name__c,Title__c,Email__c,Secondary_Email__c,Phone__c,Fax__c,
//                   Mobile__c,Mailing_Street__c,Mailing_City__c,Mailing_State__c,
//                   Mailing_Zip__c,Mailing_Country__c 
//                   FROM Lead_Contact__c 
//                   WHERE Parent_Name_del__c = :a.Lead_Convert_Id__c]; 
      
      Contact newContact = new Contact (
      AccountId = a1.Id,
      FirstName = lc.First_Name__c,
      LastName = lc.Last_Name__c,
      Title = lc.Title__c,
      Email = lc.Email__c,
      Phone = lc.Phone__c,
      Fax = lc.Fax__c,
      MobilePhone = lc.Mobile__c,
      MailingStreet = lc.Mailing_Street__c,
      MailingCity = lc.Mailing_City__c,
      MailingState = lc.Mailing_State__c,
      MailingPostalCode = lc.Mailing_Zip__c,
      MailingCountry = lc.Mailing_Country__c);
       
      insert newContact; 
        
      lc.Parent_Name_del__c = null;
       
        update lc; 
        
      ln.Account__c = a1.Id;
      
        update ln;  
        
     }
   
}

 

 

Thank you in advance for any assistance.

 

Levi

 

Hi all,

 

I am new to Visual Force and trying to create my first page!  I created a Class & VF page on the Campaign Object.  What I am trying to do is pull all of the Leads that are associated to the Campaign that have been Disqualified.

 

If I use html, I can display the data on the VF page just fine, but I would like to use APEX instead.

 

Here is the Class:

 

 

public with sharing class CampaignMetricsRL {

    public CampaignMetricsRL(ApexPages.StandardController controller) {

    }


public PageReference ViewData() {

return null;
}
 
List<Campaign> rqs;

Id cid = ApexPages.currentPage().getParameters().get('id');

 public List<Campaign> getCampaign() {

  if(rqs == null){
  rqs = [select Id, Name, Actual_Cost__c, NumberOfLeads, NumberOfContacts, NumberOfOpportunities,
         NumberOfWonOpportunities, AmountWonOpportunities, OwnerId, CreatedDate
         from Campaign
         limit 1];
  }
  return  rqs;
 }


public Integer getDQLeads() {

return [

select count() from CampaignMember

where Lead.Lead_is_Disqualified__c = True AND Campaignid = :cid
      
];

} 
}

 

Here is the Visual Force Page:

 

 

<apex:page standardController="Campaign" extensions="CampaignMetricsRL" showHeader="false">


<apex:form id="test">
  <apex:pageblock title="">

      <tr>     
           
        <apex:pageBlockTable value="{!Campaign}" var="C" id="table">
                                                     

           <apex:column >                      
              
                 <table>
 
 <tr><td align="center"></td></tr>                 
 <tr><td align="center"></td></tr>
 <tr><td align="center"><u><font size="4" color="#000000">Leads</font></u></td></tr>
 <tr><td align="center"><font size="3" color="#000000"><b>{!C.NumberOfLeads}</b></font></td></tr>                
                    
                 </table>       
            
           </apex:column> 
   
        
           <apex:column >                      
              
                 <table>

 <tr><td align="center"><u><font size="4" color="#000000">Disqualified Leads</font></u></td></tr>
 <tr><td align="center"><font size="3" color="#000000"><b>{!DQLeads}</b></font></td></tr>                
                    
                 </table>       
            
           </apex:column>
         

    
      
                
  </apex:pageblock>
    
</apex:form>


</apex:page>

 I would love to use APEX over HTML.  Any help would be appreciated!

 

Thanks,

Alex

 

 

  • September 15, 2010
  • Like
  • 0

Hi all,

 

I am trying to move a Trigger into Production but I am getting a 0% coverage when I validate it through Eclipse/Force.com.  I have 100% coverage when I run all tests in the sandbox.

 

The trigger will move the owner of an event to match the new lead owner once the lead is moved from a lead queue owner.

 

Here is the trigger and class.  I already received help from the discussion board on the trigger, thanks again in advance.

 

Any suggestions?

 

 

**** Trigger ****

trigger ownerupdate on Lead (after Update) {

List<Event> aplist = new List<Event>();

for(Lead t : Trigger.new){

IF(
(t.LeadSource == 'Telemarketing'
    && t.OwnerId != '00G30000001iNeKEAU' 
     && t.OwnerId != '00G30000001iNtxEAE'
      && t.OwnerId != '00G30000001uiO5'
       && t.OwnerId != '00G30000001iCwM'
        && t.OwnerId != '00G30000001uh70'
         && t.OwnerId != '00G30000001iNt5EAE'
          && t.OwnerId != '00G30000001ui8wEAA'
           && t.OwnerId != '00G30000001iNuC'
            && t.OwnerId != '00G30000001iNsL'
             && t.OwnerId != '00G30000001iNvZ'
              && t.OwnerId != '00G30000001jtEi'
               && t.OwnerId != '00G30000001tiXR'
                && t.OwnerId != '00G30000001ui8w'
                 && t.OwnerId != '00G30000001iNt5'
))

{List<Event> aps = [Select WhoId, Whatid, OwnerId from Event where WhoId = :t.Id];
   for (Event ap : aps)
   {       
      ap.OwnerId = t.OwnerId;

      aplist.add( ap );
   }

}}
update aplist;
}
trigger ownerupdate on Lead (after Update) {
    && t.OwnerId != '00G30000001iNeKEAU' 
**** Class Test Method **** public class ownerupdate { static testMethod void T1() { Id lId; Id eId; //CREATE 1 LEAD Lead l = new Lead(); l.LeadSource = 'Telemarketing'; l.lastname = 'Doe'; l.company = 'Test Company'; l.ownerId = '00530000003IFwV'; l.status = 'Open'; l.market__c = 'Atlanta'; Database.insert(l); lId = l.Id; //CREATE 2 Event Event e = New Event (); e.DurationInMinutes = 60; e.ActivityDateTime = date.today(); e.ownerId = l.ownerId; e.WhoId = l.Id; Database.SaveResult result = Database.insert(e); eId = e.Id; update e; {List<Lead> aps = [Select Leadsource, owner_convert_queue__c, id, OwnerId from Lead where id = :e.whoId]; system.debug('@@@apo=' + aps); } }}

 

Alex

 

  • September 01, 2010
  • Like
  • 0