• James Roberts 32
  • NEWBIE
  • 15 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 11
    Replies
I have build the following Visual Force page for a custom object (Opportunity_Pricing__c) and Standard Controller and I am trying to add a test for Code coverage, but I only get 45% coverage

Here is the visualforce page:
<apex:page standardController="Opportunity_Pricing__c" extensions="PricingTable" lightningStylesheets="true">
    <apex:slds />
    <apex:form >
       <apex:pageBlock >
           <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!save}" oncomplete="ReloadPage();" />
        </apex:pageBlockButtons>
           <table>
               <tr >
                   <th></th>
                   <th>Included</th>
                   <th>Year 1</th>
               </tr>                    
               <apex:repeat value="{!OPList}" var="a" >
                   <tr>
                       <th>Decisioning Cloud</th>
                       <td><apex:inputField value="{! a.Decisioning_Cloud_Included__c}"/></td>
                       <td><apex:inputField value="{! a.Decisioning_Cloud_Fee_Year_1__c}"/></td>
                   </tr>
                   <tr>
                       <th>Data Cloud</th>
                       <td><apex:inputField value="{! a.Data_Cloud_Included__c}"/></td>
                       <td><apex:inputField value="{! a.Data_Cloud_Fee_Year_1__c}"/></td>
                   </tr>
                    <tr>
                       <th>Solutions Cloud</th>
                       <td><apex:inputField value="{! a.Solutions_Cloud_Included__c}"/></td>
                       <td><apex:inputField value="{! a.Solutions_Cloud_Fee_Year_1__c}"/></td>
                   </tr>
                   <tr>
                       <th>Insight Cloud</th>
                       <td><apex:inputField value="{! a.Insight_Cloud_Included__c}"/></td>
                       <td><apex:inputField value="{! a.Insight_Cloud_Fee_Year_1__c}"/></td>
                   </tr>
                   <tr>
                       <th>Total Monthly Fees</th>
                       <td></td>
                       <td><apex:inputField value="{! a.Total_Fees_Year_1__c}"/></td>
                   </tr>
            </apex:repeat>
        </table>
       </apex:pageBlock>
   </apex:form>
   <script>
    function ReloadPage(){
           //alert('reload');
           var urlId = '{!$CurrentPage.parameters.Id}';
           //alert(urlId);
           window.top.location='/'+urlId;
           return false;
       }
   </script>
</apex:page>

Here is the Extension:
public class PricingTable{
 public String LId {get;set;}
 public List<Opportunity_Pricing__c> OPList {get;set;}
 public PricingTable(ApexPages.StandardController controller){
       LId = '';
       LId=System.currentPageReference().getParameters().get('id');
       System.debug('...................LID=='+LId);
       Id i= Id.valueOf(LId);
       OPList = [Select Base_Subscription_Fee_Included__c,Base_Subscription_Fee_Year_1__c,Base_Subscription_Fee_Year_2__c,Base_Subscription_Fee_Year_3__c,Base_Subscription_Fee_Year_4__c,Base_Subscription_Fee_Year_5__c,
                         Enhanced_Support_Included__c,Enhanced_Support_Fee_Year_1__c,Enhanced_Support_Fee_Year_2__c,Enhanced_Support_Fee_Year_3__c,Enhanced_Support_Fee_Year_4__c,Enhanced_Support_Fee_Year_5__c,
                         High_Availability_Included__c,High_Availability_Fee_Year_1__c,High_Availability_Fee_Year_2__c,High_Availability_Fee_Year_3__c,High_Availability_Fee_Year_4__c,High_Availability_Fee_Year_5__c,
                         Additional_Data_Connections_Included__c, Add_Data_Cons_Fees_Y1__c, Add_Data_Cons_Fees_Y2__c, Add_Data_Cons_Fees_Y3__c, Add_Data_Cons_Fees_Y4__c, Add_Data_Cons_Fees_Y5__c,
                         Adaptors_Included__c, Adaptor_Fees_Year_1__c, Adaptor_Fees_Year_2__c, Adaptor_Fees_Year_3__c,Adaptor_Fees_Year_4__c,Adaptor_Fees_Year_5__c,
                         Model_Integrations_Included__c, Model_Integration_Fees_Year_1__c, Model_Integration_Fees_Year_2__c,    Model_Integration_Fees_Year_3__c,Model_Integration_Fees_Year_4__c,Model_Integration_Fees_Year_5__c,
                         Risk_Repository_Included__c,Risk_Repository_Fees_Year_1__c,Risk_Repository_Fees_Year_2__c,Risk_Repository_Fees_Year_3__c,Risk_Repository_Fees_Year_4__c,Risk_Repository_Fees_Year_5__c,
                         SAS_Model_Included__c, SAS_Model_Fees_Year_1__c, SAS_Model_Fees_Year_2__c,SAS_Model_Fees_Year_3__c,SAS_Model_Fees_Year_4__c,SAS_Model_Fees_Year_5__c,
                         Virtual_Private_Cloud_Included__c,Virtual_Private_Cloud_Fees_Year_1__c,Virtual_Private_Cloud_Fees_Year_2__c,Virtual_Private_Cloud_Fees_Year_3__c,Virtual_Private_Cloud_Fees_Year_4__c,Virtual_Private_Cloud_Fees_Year_5__c,
                         Business_Critical_Support_Included__c,Business_Critical_Support_Fees_Year_1__c,Business_Critical_Support_Fees_Year_2__c,Business_Critical_Support_Fees_Year_3__c,Business_Critical_Support_Fees_Year_4__c,Business_Critical_Support_Fees_Year_5__c,
                         PCI_Compliance_Included__c,PCI_Compliance_Fees_Year_1__c,PCI_Compliance_Fees_Year_2__c,PCI_Compliance_Fees_Year_3__c,PCI_Compliance_Fees_Year_4__c,PCI_Compliance_Fees_Year_5__c,
                         Value_Added_Services_Included__c,Value_Added_Services_Fees_Year_1__c,Value_Added_Services_Fees_Year_2__c,Value_Added_Services_Fees_Year_3__c,Value_Added_Services_Fees_Year_4__c,Value_Added_Services_Fees_Year_5__c,
                         Total_Fees_Year_1__c,Total_Fees_Year_2__c,Total_Fees_Year_3__c,Total_Fees_Year_4__c,Total_Fees_Year_5__c,Opportunity_Product_Level__c,Pricing_Sheet_Approved__c,Average_MRR__c,Approved_MRR__c,
                         Data_Cloud_Included__c,Data_Cloud_Fee_Year_1__c,Data_Cloud_Fee_Year_2__c,Data_Cloud_Fee_Year_3__c,Data_Cloud_Fee_Year_4__c,Data_Cloud_Fee_Year_5__c,
                         Insight_Cloud_Included__c,Insight_Cloud_Fee_Year_1__c,Insight_Cloud_Fee_Year_2__c,Insight_Cloud_Fee_Year_3__c,Insight_Cloud_Fee_Year_4__c,Insight_Cloud_Fee_Year_5__c,
                         Solutions_Cloud_Included__c,Solutions_Cloud_Fee_Year_1__c,Solutions_Cloud_Fee_Year_2__c,Solutions_Cloud_Fee_Year_3__c,Solutions_Cloud_Fee_Year_4__c,Solutions_Cloud_Fee_Year_5__c,
                         Decisioning_Cloud_Included__c,Decisioning_Cloud_Fee_Year_1__c,Decisioning_Cloud_Fee_Year_2__c,Decisioning_Cloud_Fee_Year_3__c,Decisioning_Cloud_Fee_Year_4__c,Decisioning_Cloud_Fee_Year_5__c 
                         from Opportunity_Pricing__c where Id=:i];
       System.debug('.............................OPlist=='+OPList);
   }
 public PricingTable(){
   }
 public void save(){
       update OPList;
       /*PageReference pr = new PageReference('/'+OPList[0].Id);
       pr.setRedirect(true);
       return pr;*/
        }
   }

Here is the addition to the test class:
        ApexPages.StandardController sc = new ApexPages.StandardController(oppprice);
        PricingTable testPT = new PricingTable(sc);
        Test.StopTest();
I can add Regional Manager as a role on my Opportunity Team, but when I am creating an Email Alert for the Opportunity I cannot select Regional Manager as one of the Recipients from the Opportunity Team

Opp Team on Opportunity

Opp Team on Email Alert
 
I have added a Table with a Save button to my record page using VisualForce. I have a Process in Process Builder that is set to fire whenever the record is created or edited. I have noticed that when I make changes to the table and click the Save button, the Process is not fired. I have to click the button a second time (not making a change) for the Process to fire. 

Here is an extract from the Visualforce page showing the button set up:

<apex:page standardController="Opportunity_Pricing__c" extensions="PricingTable" lightningStylesheets="true">
    <apex:slds />
    <apex:form >
       <apex:pageBlock >
           <apex:pageBlockButtons location="bottom" >
               <apex:commandButton value="Save" action="{!save}" oncomplete="ReloadPage();" />
        </apex:pageBlockButtons>

    function ReloadPage(){
           //alert('reload');
           var urlId = '{!$CurrentPage.parameters.Id}';
           //alert(urlId);
           window.top.location='/'+urlId;
           return false;
       }
Our team are using the Gmail Lightning Sync to sync up their emails from Gmail into Salesforce. I want to trigger a field update process when new emails are synced to Leads or Contacts, but I can't see to find a way to trigger this. 

I've tried using simple workflow rules, processes, flows and even an Apex trigger, but none of them seem to fire when emails are sent and synced through the Gmail Lightning Plugin.

Does anyone have any solution?
Thanks
I'm having trouble adding custom error messages into my visual force table. 

I have created the Error Controller extension and added it to my VF page, but I am still getting the standard error message, without the graphic:

Update failed. First exception on row 0 with id a1H55000006jCXLEA2; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.: []
Error is in expression '{!save}' in component <apex:commandButton> in page pricingtable3years: Class.PricingTable.save: line 22, column 1

Controller:
public with sharing class ErrorMessageInVfController {
    public Opportunity_Pricing__c op{get;set;}
    public ErrorMessageInVfController(ApexPages.StandardController controller) {
        op = (Opportunity_Pricing__c)controller.getRecord();
    }
 
    public void save(){ 
      if(op.Pricing_Sheet_Approved__c = TRUE && (op.Average_MRR__c < (op.Approved_MRR__c*0.9)) )
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.'));
 
    }
}

Visual Force page Extract:
<apex:page standardController="Opportunity_Pricing__c" extensions="PricingTable,ErrorMessageInVfController" lightningStylesheets="true">
    <apex:slds />
    <apex:form >
       <apex:pageBlock >
        <apex:pageMessages id="showmsg"></apex:pageMessages>
           <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!save}" oncomplete="ReloadPage();" rerender="showmsg" />
        </apex:pageBlockButtons>
           <table>
               <tr >
                   <th></th>
                   <th>Included</th>
                   <th>Year 1</th>
                   <th>Year 2</th>
                   <th>Year 3</th>
               </tr>                    
 
Hello - I need some help translating some functionality from an Apex Trigger that has been added to my org previously by a developer. 
I've figured out most of the code, but I'm not sure what the Decimal TempCounter is and why it is used. 
Can anyone give me a line by line translation to layman's terms of the below code:

map<id,decimal> leadcounterMap = new  map<id,decimal>();
   
    Set<id> duplicateids = new Set<id>();
    
    for(Task t: (trigger.isinsert) ? trigger.New : trigger.old)
    {
        if(t.Whoid != null)
        {
            //Rollingup for Leads
            if(String.ValueOf(t.Whoid).startsWith('00Q'))
            {
                if(leadcounterMap.keyset().contains(t.Whoid))
                {
                    Decimal TempCounter = 0;
                    TempCounter = leadcounterMap.get(t.Whoid);
                    TempCounter++;
                    leadcounterMap.put(t.Whoid,TempCounter);
                }
                else
                {
                    Decimal TempCounter = 1;
                    leadcounterMap.put(t.Whoid,TempCounter);
                }
            }
 //rolling up leads activity count 
    for(Lead l : leads)
    {
        Lead TempLead = leadTaskMap.get(l.id);
                
        if(TempLead.No_Of_Activities__c == null)
            TempLead.No_Of_Activities__c = 0;
        
        if(Trigger.isInsert)
            TempLead.No_Of_Activities__c  += leadcounterMap.get(l.id);
        else if(Trigger.isDelete)
            TempLead.No_Of_Activities__c  -= leadcounterMap.get(l.id);
        
        leadstoUpdate.add(TempLead);
    }

Thanks!
James
I received this error when trying to create a Test Class for testing my Apex Controller that is part of a Lightning component described here:

https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause_cmp_record.htm

Here is my Test Class:

@isTest
public class Test_interviewsbyRecord 
{
    public TestMethod static void TestTask()
    {
        Task t = new Task();
        t.subject = 'ApexTest';
        t.ActivityDate= date.today();
        t.Status = 'Open';
        t.OwnerId = '00561000001r8ztAAA';
        insert t;
        
        List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
        
           Map <id, Task> inputs = new Map<id, Task>();
        inputs.put('TaskID',t.Id);
            
        Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
        myFlow.start();
       
    }


The test class is created a new task and then initiating the Flow (Activity_Escalation_Flow) that is running on my Tasks. The only Variable needed for the Flow is that Task ID, which is contained in the Variable !TaskID. I don't seem to be mapping it correctly to the Input.
I have a process set up on my website through a 3rd party tool whereby if someone downloads an asset, they complete a form and then are automatically loaded into Salesforce as a new Lead. I want to be able to automatically convert any new Leads that are created for Accounts that are already marked with type = Customer in Salesforce. 
 
I have created a Flow that is comparing the Company Name on a Lead to my Account Names with Type = Customer and if true, then calling the Apex class to convert the Lead. However, I would like to amend the Apex Class so that it does not create a new Account, but uses the existing account in the system. So in other words, create a contact only - no account, no opportunity. 

I think I need to use SetAccountId somewhere in the class, but I am not sure where or how to set the Account correctly - can anyone help?

Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            Leadconvert.setLeadId(LeadIds[0]);
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            Leadconvert.setConvertedStatus(Leads.MasterLabel);
            Leadconvert.setDoNotCreateOpportunity(TRUE);
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
            System.assert(Leadconverts.isSuccess());
   }
}
Hi Community,

I seem to be running into issues when trying to bind more than one picklist value in a selection. I've checked some of the forums and documentation and can't seem to find a solution for this. This is probably something simple with syntax that I'm hoping someone can help with.

We have these Forecast Categories that are similar to sales stages. They are in a picklist and only a single value (Development, Upside, Committed, Booked, Lost) can be selected per record. I can get a binding to work when one value is selected but am unable to get it to select two or more.

Custom query syntax when setting up the toggle widget. I believe the issue is with the syntax here but am not sure.

So far I've tried 'Bookings,Development', 'Bookings","Development', "Bookings","Development" and ["Bookings","Development"]. None of these combinations have worked. The chart returns 'no results found' when any toggle except Committed is selected.

User-added image

Compact view syntax that I'm using to place into the bar graphy widget. I've tried asobject and asstring and neither work.

User-added imageAny guidance here is appreciated!
I can add Regional Manager as a role on my Opportunity Team, but when I am creating an Email Alert for the Opportunity I cannot select Regional Manager as one of the Recipients from the Opportunity Team

Opp Team on Opportunity

Opp Team on Email Alert
 
Our team are using the Gmail Lightning Sync to sync up their emails from Gmail into Salesforce. I want to trigger a field update process when new emails are synced to Leads or Contacts, but I can't see to find a way to trigger this. 

I've tried using simple workflow rules, processes, flows and even an Apex trigger, but none of them seem to fire when emails are sent and synced through the Gmail Lightning Plugin.

Does anyone have any solution?
Thanks
I'm having trouble adding custom error messages into my visual force table. 

I have created the Error Controller extension and added it to my VF page, but I am still getting the standard error message, without the graphic:

Update failed. First exception on row 0 with id a1H55000006jCXLEA2; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.: []
Error is in expression '{!save}' in component <apex:commandButton> in page pricingtable3years: Class.PricingTable.save: line 22, column 1

Controller:
public with sharing class ErrorMessageInVfController {
    public Opportunity_Pricing__c op{get;set;}
    public ErrorMessageInVfController(ApexPages.StandardController controller) {
        op = (Opportunity_Pricing__c)controller.getRecord();
    }
 
    public void save(){ 
      if(op.Pricing_Sheet_Approved__c = TRUE && (op.Average_MRR__c < (op.Approved_MRR__c*0.9)) )
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.'));
 
    }
}

Visual Force page Extract:
<apex:page standardController="Opportunity_Pricing__c" extensions="PricingTable,ErrorMessageInVfController" lightningStylesheets="true">
    <apex:slds />
    <apex:form >
       <apex:pageBlock >
        <apex:pageMessages id="showmsg"></apex:pageMessages>
           <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!save}" oncomplete="ReloadPage();" rerender="showmsg" />
        </apex:pageBlockButtons>
           <table>
               <tr >
                   <th></th>
                   <th>Included</th>
                   <th>Year 1</th>
                   <th>Year 2</th>
                   <th>Year 3</th>
               </tr>                    
 
I received this error when trying to create a Test Class for testing my Apex Controller that is part of a Lightning component described here:

https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause_cmp_record.htm

Here is my Test Class:

@isTest
public class Test_interviewsbyRecord 
{
    public TestMethod static void TestTask()
    {
        Task t = new Task();
        t.subject = 'ApexTest';
        t.ActivityDate= date.today();
        t.Status = 'Open';
        t.OwnerId = '00561000001r8ztAAA';
        insert t;
        
        List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
        
           Map <id, Task> inputs = new Map<id, Task>();
        inputs.put('TaskID',t.Id);
            
        Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
        myFlow.start();
       
    }


The test class is created a new task and then initiating the Flow (Activity_Escalation_Flow) that is running on my Tasks. The only Variable needed for the Flow is that Task ID, which is contained in the Variable !TaskID. I don't seem to be mapping it correctly to the Input.
I have a process set up on my website through a 3rd party tool whereby if someone downloads an asset, they complete a form and then are automatically loaded into Salesforce as a new Lead. I want to be able to automatically convert any new Leads that are created for Accounts that are already marked with type = Customer in Salesforce. 
 
I have created a Flow that is comparing the Company Name on a Lead to my Account Names with Type = Customer and if true, then calling the Apex class to convert the Lead. However, I would like to amend the Apex Class so that it does not create a new Account, but uses the existing account in the system. So in other words, create a contact only - no account, no opportunity. 

I think I need to use SetAccountId somewhere in the class, but I am not sure where or how to set the Account correctly - can anyone help?

Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            Leadconvert.setLeadId(LeadIds[0]);
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            Leadconvert.setConvertedStatus(Leads.MasterLabel);
            Leadconvert.setDoNotCreateOpportunity(TRUE);
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
            System.assert(Leadconverts.isSuccess());
   }
}