• Travis Lee 1
  • NEWBIE
  • 135 Points
  • Member since 2015

  • Chatter
    Feed
  • 2
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 29
    Replies
I have a Field on account called Isactive__c   which is checkbox type and i want when ever checkbox is true
Account number field (standrad field) becomes read only . If there is existing value then it can be only viewed but if there is no value you cant edit it (only by customization, no use of trigger or apex)
I created a Validation Rule. The validation rule (set on Billing_State field), was created to insure if a lead record contact is listing an address in the US or Canada their State can only contain a two letter abbreviation and must be an abbreviation relative to a US State i.e. CA, WA, NY etc. But we get some foreign records coming in that are precluded from Salesforce because in some countries the state/province is more than 2 letters ex: North Rhine-Westphalia Germany = NRW. This is the rule:

AND( 
NOT(ISBLANK(BillingState)), 
OR( 
LEN(BillingState) <> 2, 
NOT( 
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & 
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & 
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & 
"WA:WV:WI:WY:PR:" & "AB:BC:MB:NB:NL:NT:NU:ON:PE:QC:SK:YT", BillingState) 
)))

But here is my question, how can I write a Validation Rule that will allow for us to maintain data integrity yet still meet the need of allowing records into Salesforce where its a foreign country with longer state abbreviations?

Thanks in advance for any help,

Glenn
Let me first start by saying I understand how to calculate the number of days between two dates. The bigger issue I need help with (that wouldn't fit in the title) is how to correctly allocate the days between those two dates to the correct periods. I found an old thread that was never solved that gave the perfect example:

Here's a good example that should clarify what I need:
Start_Date__c 6/29/11, End_Date__c is 10/20/1. I need to know: there are 2 Days Revenue in Q2.  92 Days Revenue for Q3, and 20 Revenue Days in Q4.

It's a formula to calculate the 2 days, 92 days, 20 days that I truly need to figure out in order to properly allocate daily spend for an advertising company. Most of what needs to happen exists in visual workflow currently, this formula would get plugged in to a bulkified visual workflow that assigns currency values to revenue schedule installments.

Any help would be appreciated!
Hey there!

I'm a Senior Admin looking for projects I can complete on a remote basis. I'm 6X Certified and working to expand my knowledge in different types of orgs! Core competencies include the following:

-Process Automation
-Configuration/Customizations
-Reporting
-Visual Workflow
-Data Migration
-Solutions Testing

I have reasonable rates and will negotiate based on timing/project. Happy to provide references, resume and other evidence of certification upon request!

Thanks,

Travis
Hi Everyone,

Combing through curent threads, I found a lot of people addressing Step 2, but not this particular error that I seem to keep getting. I've double-checked naming conventions and security folders but I continue to get the below error. Any advice? Other threads I should be looking at?

User-added image

Thanks!
Hi Forum Community,

I'm attempting to create a panel grid using Visualforce for sellers to enter in values to the Opportunity object for the purposes of a custom forecasting tool. I've got a rough draft of a page that I've included the code for here. I'm trying to accomplish two things:

1. I can't seem to display this page as anything other than a listview button? Not sure what I've done to restrict it's accessibility to a tab override or a custom link?

2. Include filters that are subject to the role hierarchy (create options for My Opps and My Team's Opps similar to standard functionality)?

Open to any suggestions that might exist!
 
<apex:page standardController="Opportunity" recordSetVar="opps">
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                 <apex:commandButton value="Quick Save" action="{!quicksave}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!opps}" var="opp">
 
                <apex:column value="{!opp.Account.Name}"/>
                <apex:column headerValue="Current Goal Amount" value="{!opp.Account.Current_Quarter_Goal__c}"/>
                                                
                <apex:column headerValue="Probability">
                    <apex:inputField value="{!opp.Probability}"/>
                </apex:column>

                <apex:column headerValue="Goal Amount">
                    <apex:inputField value="{!opp.Account.Current_Quarter_Goal__c}"/>
                </apex:column>
                                    
                <apex:column headerValue="Digital Booked">
                    <apex:inputField value="{!opp.Digital_Booked__c}"/>
                </apex:column>
                
                <apex:column headerValue="Digital Pipeline">
                    <apex:inputField value="{!opp.Digital_Pipeline__c}"/>
                </apex:column>
                
                <apex:column headerValue="PTV Booked">
                    <apex:inputField value="{!opp.PTV_Booked__c}"/>
                </apex:column>
                
                <apex:column headerValue="PTV Pipeline">
                    <apex:inputField value="{!opp.PTV_Pipeline__c}"/>
                </apex:column>
            </apex:pageBlockTable>     
            <apex:panelGrid columns="2">
                  <apex:commandLink action="{!first}">First</apex:commandlink>
      <apex:commandLink action="{!last}">Last</apex:commandlink>
      <apex:commandLink action="{!previous}">Previous</apex:commandlink>
      <apex:commandLink action="{!next}">Next</apex:commandlink>
    </apex:panelGrid> 
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
When checking this challenge, I get an error stating that the quickContact Lightning Component could not be found. Including screenshots of the steps I took thus far. Any advice would be appreciated!

1. The Lightning component must be named quickContact (this comes as part of the package, confirmed in picture below)
User-added image

2. Create a new action with Label Quick Contact and Name Quick_Contact on the Account object that invokes the quickContact component. (confirmed in picture below)
User-added image
3. Add the appropriate interfaces to the quickContact component. (Hint: there are two.) (used the implements force:lightningquickaction AND the force:hasrecordid on line 1, confirmed in picture below)
User-added image

4. Add the action to the Account Layout page layout. (added in picture below)
User-added image
Hi there,

I'm attempting to cobble together some code for a lead convert trigger that will (after update, after insert) ensure the resulting Account's name is the Last Name plus the last 4 digits of the phone number and I'm a little stuck. For example, if you were converting a lead named John Smith and his phone number was 123-456-7890, the resulting account would be called "Smith-7890". The piece for the trigger to autoconvert works fine, but the portion updating the account is giving me from trouble. Any advice would be appreciated!
trigger LeadConvert on Lead (after insert,after update) {
//Bulkified
    List<String> LeadNames = new List<String>{};
        for(Lead myLead: Trigger.new){
         if((myLead.isconverted==false) && (myLead.Status == 'Scheduled Appointment')) {
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(myLead.Id);
            lc.convertedStatus = 'Scheduled Appointment';
        //Database.ConvertLead(lc,true);
            lc.setDoNotCreateOpportunity(true);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            System.assert(lcr.isSuccess());
            }
        }
        List <Account> account = [SELECT acc.Id, acc.Description FROM Account acc WHERE acc.Id = :Trigger.new.ConvertedAccountId];
        for (Account acc: account) {
    	acc.Name = Trigger.new.LastName + Trigger.new.RIGHT(Phone, 4);
        update acc;
    }
}

 
Hey everyone, I'm a new developer trying to understand the intricacies of apex code to be a bit more self sufficient. I'm still a bit hazy on proper test classes so what you'll see below are the class that I'm using to compile a score for contracts and the test class for it. The test class currently has 81% coverage so it will deploy but I have the feeling it could be done more efficiently? Any suggestions are welcome! It's a little lengthy...

public class ContractScore
{
    // Methods for scoring Contracts..
    
    public static void scoreContract(List<Contract> cons)  
    {
        // Entry point, runs all scoring methods on list of Contracts
                   
        // Handle existing contracts that may have a null value in the Score__c field
        for(Contract con : cons)
        {
          con.Score__c = 0;
        }
        
        // Call individual scoring methods
        scoreConTechFee(cons);
        scoreConMinFeeCommit(cons);
        scoreConProjectedAnnualSpend(cons);
    scoreConPlatServFee(cons);
    scoreConMarginMgmtFee(cons);
    scoreConDataAccessFee(cons);
    scoreConCertTraining(cons);
    scoreConCampaignMgmtFee(cons);
    scoreConAcctSetupFee(cons);
    // etc..
        
        // Update contract scores
        update cons;
    }
    
    public static void scoreConTechFee(List<Contract> cons)
    {
        // Score Contracts based on Campaign Tech Fee (Contract object)
  
        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Campaign_Technology_Fee__c >= 0.20){
        con.Score__c += 35;
      } else if (con.Campaign_Technology_Fee__c < 0.20 && con.Campaign_Technology_Fee__c >= 0.18 ) {
        con.Score__c += 30;
      } else if (con.Campaign_Technology_Fee__c < 0.18 && con.Campaign_Technology_Fee__c >= 0.17) {
        con.Score__c += 25;
      } else if (con.Campaign_Technology_Fee__c < 0.17 && con.Campaign_Technology_Fee__c >= 0.15) {
        con.Score__c += 20;
      } else if (con.Campaign_Technology_Fee__c < 0.15 && con.Campaign_Technology_Fee__c >= 0.13) {
        con.Score__c += 15;  
    } else if (con.Campaign_Technology_Fee__c < 0.13 && con.Campaign_Technology_Fee__c >= 0.11) {
        con.Score__c += 10;
    } else if (con.Campaign_Technology_Fee__c < 0.11) {
        con.Score__c += 5;
    }  else {
        con.Score__c += 0;    
    }
    }
  }

    public static void scoreConMinFeeCommit(List<Contract> cons)
    {
        // Score Contracts based on Minimum Annual Fee Commitment (Contract object)
   
        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Minimum_Annual_Fee_Commitment__c < 100000){  
        con.Score__c += 0;
      } else if (con.Minimum_Annual_Fee_Commitment__c >= 100000 && con.Minimum_Annual_Fee_Commitment__c <= 200000) {
        con.Score__c += 10;
      } else if (con.Minimum_Annual_Fee_Commitment__c > 200000 && con.Minimum_Annual_Fee_Commitment__c <= 400000){
        con.Score__c += 15;
      } else if (con.Minimum_Annual_Fee_Commitment__c > 400000 && con.Minimum_Annual_Fee_Commitment__c <= 600000){
        con.Score__c += 20;
      } else if (con.Minimum_Annual_Fee_Commitment__c > 600000 && con.Minimum_Annual_Fee_Commitment__c <= 800000){
        con.Score__c += 25;
    } else if (con.Minimum_Annual_Fee_Commitment__c > 800000 && con.Minimum_Annual_Fee_Commitment__c <= 1000000){
        con.Score__c += 30;
    } else if (con.Minimum_Annual_Fee_Commitment__c > 1000000){
        con.Score__c += 50;
    } else {
        con.Score__c += 0;
      }    
    }
  }

    
    public static void scoreConProjectedAnnualSpend(List<Contract> cons)
    {
        // Score Contracts based on Projected Annual Spend (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Projected_Annual_Spend__c < 2000000){
        con.Score__c += 0;
      } else if (con.Projected_Annual_Spend__c >= 2000000 && con.Projected_Annual_Spend__c <= 4000000) {
        con.Score__c += 10;
      } else if (con.Projected_Annual_Spend__c > 4000000 && con.Projected_Annual_Spend__c <= 6000000){
        con.Score__c += 15;
      } else if (con.Projected_Annual_Spend__c > 6000000 && con.Projected_Annual_Spend__c <= 8000000){
        con.Score__c += 20;
      } else if (con.Projected_Annual_Spend__c > 8000000 && con.Projected_Annual_Spend__c <= 10000000){
        con.Score__c += 30;
      } else if (con.Projected_Annual_Spend__c > 10000000){
        con.Score__c += 50;
    } else {
        con.Score__c += 0;
      }  
    }
    }

    
  public static void scoreConPlatServFee(List<Contract> cons)
    {
        // Score Contracts based on Platinum Account Services Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Platinum_Account_Services_Fee__c < 0.05){
        con.Score__c -= 5;
      } else if (con.Platinum_Account_Services_Fee__c >=  0.05 ) {
        con.Score__c += 5;
      } else {
        con.Score__c += 0;
      }  
    }
    }
  
  public static void scoreConMarginMgmtFee(List<Contract> cons)
    {
        // Score Contracts based on Margin Management Module Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Margin_Management_Module_Fee__c < 0.03){
        con.Score__c -= 5;
      } else if (con.Margin_Management_Module_Fee__c >=  0.03) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConDataAccessFee(List<Contract> cons)
    {
        // Score Contracts based on Data Access and Integration Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Data_Access_and_Integration_Fee__c < 0.03){
        con.Score__c -= 5;
      } else if (con.Data_Access_and_Integration_Fee__c >=  0.03) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConCertTraining(List<Contract> cons)
    {
        // Score Contracts based on Certification and Training Programs (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Certification_and_Training_Programs__c < 3500){
        con.Score__c -= 5;
      } else if (con.Certification_and_Training_Programs__c >=  3500) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConCampaignMgmtFee(List<Contract> cons)
    {
        // Score Contracts based on Campaign Management Service Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Campaign_Management_Service_Fee__c < 0.10){
        con.Score__c -= 5;
      } else if (con.Campaign_Management_Service_Fee__c >=  0.10) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConAcctSetupFee(List<Contract> cons)
    {
        // Score Contracts based on Account Set Up Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Account_Set_Up_Fee__c < 10000){
        con.Score__c -= 5;
      } else if (con.Account_Set_Up_Fee__c >=  10000) {
        con.Score__c += 5;
      } 
    }
    }
    // Other methods here
}

--------------------------------------------------------------------------------

@isTest (SeeAllData = true)
public class conScoreTest {
public static testMethod void validateConScoreTest(){

  Account Acc = new Account();
        
    Acc.Name = 'TestAccount';
    Acc.Customer_Segment__c = 'Agency';
    Acc.CurrencyIsoCode = 'USD';
  Acc.Type = 'Prospect';
        
    Insert Acc;
    
  Opportunity Opp = new Opportunity();
  
  Opp.Name = 'TestOppNew';
    Opp.AccountId = Acc.Id;
    Opp.CloseDate = System.Today().addDays(10);
    Opp.StageName = 'Campaign Pitch';
    Opp.Type = 'Media';
    Opp.Projected_Start_Date__c = System.Today().addDays(15);
    Opp.Projected_Annual_Spend__c = 3000000;
    Opp.Annual_Commitment__c = 200000;
            
    Insert Opp;   
        
  Contract Con = new Contract();

  Con.AccountId = Acc.Id;
  Con.Opportunity__c = Opp.Id;
  Con.Status = 'Draft';
  Con.Fee_Commitment_Type__c = 'Minimum Fee Commitment';
  Con.ContractTerm = 12;
  Con.Campaign_Technology_Fee__c = 0.18;
  Con.Score__c = 0;
  Con.Platinum_Account_Services_Fee__c = 0.05;
  Con.Margin_Management_Module_Fee__c = 0.03;
  Con.Data_Access_and_Integration_Fee__c = 0.03;
  Con.Certification_and_Training_Programs__c = 3500;
  Con.Campaign_Management_Service_Fee__c = 0.10;
  Con.Account_Set_Up_Fee__c = 10000;
  
  Insert Con;
  
  Con.Campaign_Technology_Fee__c = 0.20;
  Con.Platinum_Account_Services_Fee__c = 0.07;
  Con.Margin_Management_Module_Fee__c = 0.05;
  Con.Data_Access_and_Integration_Fee__c = 0.05;
  Con.Certification_and_Training_Programs__c = 5000;
  Con.Campaign_Management_Service_Fee__c = 0.12;
  Con.Account_Set_Up_Fee__c = 20000;
            
    Update Con;     
    
    Con.Campaign_Technology_Fee__c = 0.16;
  Con.Platinum_Account_Services_Fee__c = 0.04;
  Con.Margin_Management_Module_Fee__c = 0.02;
  Con.Data_Access_and_Integration_Fee__c = 0.02;
  Con.Certification_and_Training_Programs__c = 2000;
  Con.Campaign_Management_Service_Fee__c = 0.09;
  Con.Account_Set_Up_Fee__c = 9000;
    
     Update Con;
        
    // tjl - test method
    List<Contract> conList = new List<Contract>();
    conList.add(Con);
    
    ContractScore.scoreContract(conList);
  }
}

 
I'm attempting to adjust an existing visualforce page from a previous regime by adding a couple conditions to it. Here is the existing code:

<apex:page standardController="Opportunity">
<apex:form >
<script>

window.document.onload = new function(e)
{
  if({!Opportunity.Has_Revenue_Schedule__c==FALSE})
   {
    alert("Please establish a revenue schedule for this opportunity.");
  } 
}
</script>
</apex:form>
</apex:page>

Right now, when you open up an Opportunity and the custom field Has Revenue Schedule is unchecked, a window pops up with an alert asking the user to please establish a revenue schedule for this opportunity. And all I want to do is add a condition that says this alert pops up when Has Revenue Schedule is unchecked AND the Current User's ID is equal to the Opportunity Owner's ID. Thought it should look something like this:

<apex:page standardController="Opportunity">
<apex:form >
<script>

window.document.onload = new function(e)
{
  if({!Opportunity.Has_Revenue_Schedule__c==FALSE} AND {!$User.Id == !Opportunity.OwnerId})
   {
    alert("Please establish a revenue schedule for this opportunity.");
  } 
}
</script>
</apex:form>
</apex:page>

But I'm very green when it comes to Visualforce/Apex and I can't figure out what I'm doing wrong syntactically. It's probably something simple but I just can't seem to see past it. Any help would be much appreciated!
When checking this challenge, I get an error stating that the quickContact Lightning Component could not be found. Including screenshots of the steps I took thus far. Any advice would be appreciated!

1. The Lightning component must be named quickContact (this comes as part of the package, confirmed in picture below)
User-added image

2. Create a new action with Label Quick Contact and Name Quick_Contact on the Account object that invokes the quickContact component. (confirmed in picture below)
User-added image
3. Add the appropriate interfaces to the quickContact component. (Hint: there are two.) (used the implements force:lightningquickaction AND the force:hasrecordid on line 1, confirmed in picture below)
User-added image

4. Add the action to the Account Layout page layout. (added in picture below)
User-added image
I have a requirement to show a modal with some text prior to creating a NEW record.   Ideally, a user would CLICK new to create a new opportunity, and would see a modal popup with text message.  She/he would then click a navigation button 'continue' to open the normal NEW record modal and create the new record.   No inputs are needed-  just a text message.  

I need this to work in Lightning and CLassic.  I wanted to do this with a FLOW/Process builder, but I see that you can't launch a screen flow from Process builder.   

How should I approach this so that it works in both Classic and Lightning?    

Thank you!  
Let me first start by saying I understand how to calculate the number of days between two dates. The bigger issue I need help with (that wouldn't fit in the title) is how to correctly allocate the days between those two dates to the correct periods. I found an old thread that was never solved that gave the perfect example:

Here's a good example that should clarify what I need:
Start_Date__c 6/29/11, End_Date__c is 10/20/1. I need to know: there are 2 Days Revenue in Q2.  92 Days Revenue for Q3, and 20 Revenue Days in Q4.

It's a formula to calculate the 2 days, 92 days, 20 days that I truly need to figure out in order to properly allocate daily spend for an advertising company. Most of what needs to happen exists in visual workflow currently, this formula would get plugged in to a bulkified visual workflow that assigns currency values to revenue schedule installments.

Any help would be appreciated!
I have a Field on account called Isactive__c   which is checkbox type and i want when ever checkbox is true
Account number field (standrad field) becomes read only . If there is existing value then it can be only viewed but if there is no value you cant edit it (only by customization, no use of trigger or apex)
I’m having a hard time visualising how this would work. I need the ability to type up an SOW in Salesforce. Once I finish typing the SOW and want to send it to the customer, I should have a button that sends to a specific recipient. The client then should have the ability to sign the SOW and save it. One it is saved by the client, it should automatically attach to the Development request form(Custom object) in Salesforce for Billing.
Here is the process.
Account Management receives or creates a development request form(VF page- sales the value in Salesforce custom object) (RF-XXXXXX).
Account Management types up an SOW and clicks send to the client.
The client reviews and signs the SOW. (We need the ability for the client to leave notes on the SOW. We need the ability to retract or update the SOW in case of errors)
SOW automatically finds its way to the initial request form and attaches itself there.
Accounting bills for the Development.
Please advise
Salesforce team,

Is there a way that I can track the total number of calls/emails for a given contact? For instance there could be a field thats "Number of calls" then the same for emails.
hi im trying to define a new view with some 3 filter :
i put in the first filter that the date must be more than (for ex :01/01/1900) and in the second the date must be less than 01/01/2050,
and the filter logic i put that 3 OR (1 AND 2).
but i have a message error,:(
so if you have other formulas to do that,because just i would like to control if the object was treated late with respect to a certain date
thank you in advance
best regards.
 
When checking this challenge, I get an error stating that the quickContact Lightning Component could not be found. Including screenshots of the steps I took thus far. Any advice would be appreciated!

1. The Lightning component must be named quickContact (this comes as part of the package, confirmed in picture below)
User-added image

2. Create a new action with Label Quick Contact and Name Quick_Contact on the Account object that invokes the quickContact component. (confirmed in picture below)
User-added image
3. Add the appropriate interfaces to the quickContact component. (Hint: there are two.) (used the implements force:lightningquickaction AND the force:hasrecordid on line 1, confirmed in picture below)
User-added image

4. Add the action to the Account Layout page layout. (added in picture below)
User-added image
I created a Validation Rule. The validation rule (set on Billing_State field), was created to insure if a lead record contact is listing an address in the US or Canada their State can only contain a two letter abbreviation and must be an abbreviation relative to a US State i.e. CA, WA, NY etc. But we get some foreign records coming in that are precluded from Salesforce because in some countries the state/province is more than 2 letters ex: North Rhine-Westphalia Germany = NRW. This is the rule:

AND( 
NOT(ISBLANK(BillingState)), 
OR( 
LEN(BillingState) <> 2, 
NOT( 
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & 
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & 
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & 
"WA:WV:WI:WY:PR:" & "AB:BC:MB:NB:NL:NT:NU:ON:PE:QC:SK:YT", BillingState) 
)))

But here is my question, how can I write a Validation Rule that will allow for us to maintain data integrity yet still meet the need of allowing records into Salesforce where its a foreign country with longer state abbreviations?

Thanks in advance for any help,

Glenn
Hi there,

I'm attempting to cobble together some code for a lead convert trigger that will (after update, after insert) ensure the resulting Account's name is the Last Name plus the last 4 digits of the phone number and I'm a little stuck. For example, if you were converting a lead named John Smith and his phone number was 123-456-7890, the resulting account would be called "Smith-7890". The piece for the trigger to autoconvert works fine, but the portion updating the account is giving me from trouble. Any advice would be appreciated!
trigger LeadConvert on Lead (after insert,after update) {
//Bulkified
    List<String> LeadNames = new List<String>{};
        for(Lead myLead: Trigger.new){
         if((myLead.isconverted==false) && (myLead.Status == 'Scheduled Appointment')) {
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(myLead.Id);
            lc.convertedStatus = 'Scheduled Appointment';
        //Database.ConvertLead(lc,true);
            lc.setDoNotCreateOpportunity(true);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            System.assert(lcr.isSuccess());
            }
        }
        List <Account> account = [SELECT acc.Id, acc.Description FROM Account acc WHERE acc.Id = :Trigger.new.ConvertedAccountId];
        for (Account acc: account) {
    	acc.Name = Trigger.new.LastName + Trigger.new.RIGHT(Phone, 4);
        update acc;
    }
}

 
Hi,

We have D&B(Data.com) Heirarchy Structure in our Org on the Accounts. Has any one seen below error message while updating the Opportunity Record?

"Error:A immediate parent name can't be the child of a client it's already a parent of."

There are no Validation Rule or triggers in my org with this message.  I am thinking while updating the opportunity something is triggering the D&B data on the Account.

Please let us know your thoughts

Thanks

Thanks
 
  • August 22, 2016
  • Like
  • 0
Hey everyone, I'm a new developer trying to understand the intricacies of apex code to be a bit more self sufficient. I'm still a bit hazy on proper test classes so what you'll see below are the class that I'm using to compile a score for contracts and the test class for it. The test class currently has 81% coverage so it will deploy but I have the feeling it could be done more efficiently? Any suggestions are welcome! It's a little lengthy...

public class ContractScore
{
    // Methods for scoring Contracts..
    
    public static void scoreContract(List<Contract> cons)  
    {
        // Entry point, runs all scoring methods on list of Contracts
                   
        // Handle existing contracts that may have a null value in the Score__c field
        for(Contract con : cons)
        {
          con.Score__c = 0;
        }
        
        // Call individual scoring methods
        scoreConTechFee(cons);
        scoreConMinFeeCommit(cons);
        scoreConProjectedAnnualSpend(cons);
    scoreConPlatServFee(cons);
    scoreConMarginMgmtFee(cons);
    scoreConDataAccessFee(cons);
    scoreConCertTraining(cons);
    scoreConCampaignMgmtFee(cons);
    scoreConAcctSetupFee(cons);
    // etc..
        
        // Update contract scores
        update cons;
    }
    
    public static void scoreConTechFee(List<Contract> cons)
    {
        // Score Contracts based on Campaign Tech Fee (Contract object)
  
        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Campaign_Technology_Fee__c >= 0.20){
        con.Score__c += 35;
      } else if (con.Campaign_Technology_Fee__c < 0.20 && con.Campaign_Technology_Fee__c >= 0.18 ) {
        con.Score__c += 30;
      } else if (con.Campaign_Technology_Fee__c < 0.18 && con.Campaign_Technology_Fee__c >= 0.17) {
        con.Score__c += 25;
      } else if (con.Campaign_Technology_Fee__c < 0.17 && con.Campaign_Technology_Fee__c >= 0.15) {
        con.Score__c += 20;
      } else if (con.Campaign_Technology_Fee__c < 0.15 && con.Campaign_Technology_Fee__c >= 0.13) {
        con.Score__c += 15;  
    } else if (con.Campaign_Technology_Fee__c < 0.13 && con.Campaign_Technology_Fee__c >= 0.11) {
        con.Score__c += 10;
    } else if (con.Campaign_Technology_Fee__c < 0.11) {
        con.Score__c += 5;
    }  else {
        con.Score__c += 0;    
    }
    }
  }

    public static void scoreConMinFeeCommit(List<Contract> cons)
    {
        // Score Contracts based on Minimum Annual Fee Commitment (Contract object)
   
        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Minimum_Annual_Fee_Commitment__c < 100000){  
        con.Score__c += 0;
      } else if (con.Minimum_Annual_Fee_Commitment__c >= 100000 && con.Minimum_Annual_Fee_Commitment__c <= 200000) {
        con.Score__c += 10;
      } else if (con.Minimum_Annual_Fee_Commitment__c > 200000 && con.Minimum_Annual_Fee_Commitment__c <= 400000){
        con.Score__c += 15;
      } else if (con.Minimum_Annual_Fee_Commitment__c > 400000 && con.Minimum_Annual_Fee_Commitment__c <= 600000){
        con.Score__c += 20;
      } else if (con.Minimum_Annual_Fee_Commitment__c > 600000 && con.Minimum_Annual_Fee_Commitment__c <= 800000){
        con.Score__c += 25;
    } else if (con.Minimum_Annual_Fee_Commitment__c > 800000 && con.Minimum_Annual_Fee_Commitment__c <= 1000000){
        con.Score__c += 30;
    } else if (con.Minimum_Annual_Fee_Commitment__c > 1000000){
        con.Score__c += 50;
    } else {
        con.Score__c += 0;
      }    
    }
  }

    
    public static void scoreConProjectedAnnualSpend(List<Contract> cons)
    {
        // Score Contracts based on Projected Annual Spend (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Projected_Annual_Spend__c < 2000000){
        con.Score__c += 0;
      } else if (con.Projected_Annual_Spend__c >= 2000000 && con.Projected_Annual_Spend__c <= 4000000) {
        con.Score__c += 10;
      } else if (con.Projected_Annual_Spend__c > 4000000 && con.Projected_Annual_Spend__c <= 6000000){
        con.Score__c += 15;
      } else if (con.Projected_Annual_Spend__c > 6000000 && con.Projected_Annual_Spend__c <= 8000000){
        con.Score__c += 20;
      } else if (con.Projected_Annual_Spend__c > 8000000 && con.Projected_Annual_Spend__c <= 10000000){
        con.Score__c += 30;
      } else if (con.Projected_Annual_Spend__c > 10000000){
        con.Score__c += 50;
    } else {
        con.Score__c += 0;
      }  
    }
    }

    
  public static void scoreConPlatServFee(List<Contract> cons)
    {
        // Score Contracts based on Platinum Account Services Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Platinum_Account_Services_Fee__c < 0.05){
        con.Score__c -= 5;
      } else if (con.Platinum_Account_Services_Fee__c >=  0.05 ) {
        con.Score__c += 5;
      } else {
        con.Score__c += 0;
      }  
    }
    }
  
  public static void scoreConMarginMgmtFee(List<Contract> cons)
    {
        // Score Contracts based on Margin Management Module Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Margin_Management_Module_Fee__c < 0.03){
        con.Score__c -= 5;
      } else if (con.Margin_Management_Module_Fee__c >=  0.03) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConDataAccessFee(List<Contract> cons)
    {
        // Score Contracts based on Data Access and Integration Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Data_Access_and_Integration_Fee__c < 0.03){
        con.Score__c -= 5;
      } else if (con.Data_Access_and_Integration_Fee__c >=  0.03) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConCertTraining(List<Contract> cons)
    {
        // Score Contracts based on Certification and Training Programs (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Certification_and_Training_Programs__c < 3500){
        con.Score__c -= 5;
      } else if (con.Certification_and_Training_Programs__c >=  3500) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConCampaignMgmtFee(List<Contract> cons)
    {
        // Score Contracts based on Campaign Management Service Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Campaign_Management_Service_Fee__c < 0.10){
        con.Score__c -= 5;
      } else if (con.Campaign_Management_Service_Fee__c >=  0.10) {
        con.Score__c += 5;
      } 
    }
    }
  
  
  public static void scoreConAcctSetupFee(List<Contract> cons)
    {
        // Score Contracts based on Account Set Up Fee (Contract object)

        // Loop through cons and add score
        for(Contract con : cons)
        {
            // Find proper picklist option and add value to score
            if(con.Account_Set_Up_Fee__c < 10000){
        con.Score__c -= 5;
      } else if (con.Account_Set_Up_Fee__c >=  10000) {
        con.Score__c += 5;
      } 
    }
    }
    // Other methods here
}

--------------------------------------------------------------------------------

@isTest (SeeAllData = true)
public class conScoreTest {
public static testMethod void validateConScoreTest(){

  Account Acc = new Account();
        
    Acc.Name = 'TestAccount';
    Acc.Customer_Segment__c = 'Agency';
    Acc.CurrencyIsoCode = 'USD';
  Acc.Type = 'Prospect';
        
    Insert Acc;
    
  Opportunity Opp = new Opportunity();
  
  Opp.Name = 'TestOppNew';
    Opp.AccountId = Acc.Id;
    Opp.CloseDate = System.Today().addDays(10);
    Opp.StageName = 'Campaign Pitch';
    Opp.Type = 'Media';
    Opp.Projected_Start_Date__c = System.Today().addDays(15);
    Opp.Projected_Annual_Spend__c = 3000000;
    Opp.Annual_Commitment__c = 200000;
            
    Insert Opp;   
        
  Contract Con = new Contract();

  Con.AccountId = Acc.Id;
  Con.Opportunity__c = Opp.Id;
  Con.Status = 'Draft';
  Con.Fee_Commitment_Type__c = 'Minimum Fee Commitment';
  Con.ContractTerm = 12;
  Con.Campaign_Technology_Fee__c = 0.18;
  Con.Score__c = 0;
  Con.Platinum_Account_Services_Fee__c = 0.05;
  Con.Margin_Management_Module_Fee__c = 0.03;
  Con.Data_Access_and_Integration_Fee__c = 0.03;
  Con.Certification_and_Training_Programs__c = 3500;
  Con.Campaign_Management_Service_Fee__c = 0.10;
  Con.Account_Set_Up_Fee__c = 10000;
  
  Insert Con;
  
  Con.Campaign_Technology_Fee__c = 0.20;
  Con.Platinum_Account_Services_Fee__c = 0.07;
  Con.Margin_Management_Module_Fee__c = 0.05;
  Con.Data_Access_and_Integration_Fee__c = 0.05;
  Con.Certification_and_Training_Programs__c = 5000;
  Con.Campaign_Management_Service_Fee__c = 0.12;
  Con.Account_Set_Up_Fee__c = 20000;
            
    Update Con;     
    
    Con.Campaign_Technology_Fee__c = 0.16;
  Con.Platinum_Account_Services_Fee__c = 0.04;
  Con.Margin_Management_Module_Fee__c = 0.02;
  Con.Data_Access_and_Integration_Fee__c = 0.02;
  Con.Certification_and_Training_Programs__c = 2000;
  Con.Campaign_Management_Service_Fee__c = 0.09;
  Con.Account_Set_Up_Fee__c = 9000;
    
     Update Con;
        
    // tjl - test method
    List<Contract> conList = new List<Contract>();
    conList.add(Con);
    
    ContractScore.scoreContract(conList);
  }
}

 

Any help with this solution is greatly appreciated!

 

Advertising company needs to report the Qtrly revenue amount, for ads running. More specifically: $Amount for deals with Prob > 50%, where the ad run date(s) encompasses X Qtr.

 

Here are the fields I have and an example:

  • Amount $12,000.00 [standard field]
  • Start Date 8/15/2011 [custom field created]  
  • End Date 10/20/2011 [custom field created] 
  • Number of run days: 67 [custom field: End_Date__c - Start_Date__c +1]
  • daily rate: 179.10 [custom field: Amount / Number_of_Run_days__c]

Desired results for reporting:


Total Days

Total Amount

Q3

47

$8,417.91

Q4

20

$3,582.09

 

Ref details for this example:

17 days (8/15/2011 -8/31/2011) 17*179.10= 3,044.78

30 days (9/1/2011-9/30/2011) 30*179.10= 5,373.13

20 days (10/1/2011-10/20/2011) 20*179.10= 3,582.09

 

Thank you for your time!

Karen