• Pete Watson 5
  • NEWBIE
  • 35 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 19
    Replies
I am trying to present a single visualforce table (with filters and custom chart) to display records from multiple objects (standard and custom objects) in a single table.

Is there a way to do this? If so any advise would be greatly appreciated.
Hi, 

I have a requirement to route cases (by record type) via omni channel to agents based on their presence status. 

e.g. We have a number of agents that work in multiple areas of the support teams depending on workload and seasonality. So an agent may be working on 1 type of case in the AM and a different type in the PM, or from one day to the next etc. 

If we have 2 online presence status' (e.g. 'Available for orders cases' and 'Available for service cases') is there a way we can we route different case types to the agents based on these presence status' so they can swap between work functions as and when required?

Many thanks in advance!
Pete 

 
Hi all, 

I have created a gannt chart via the google charts api and all is working great appart from the Percent Complete variable which is showing as 'null' on the tooltip. 

I have tried a number of different options to set the variable (debug logs show the varable from the controller is correct so i'm assuming its the way im assigning it in the js but not sure where i've gone wrong... any help would be greatly appreciated. 

many thanks in advance. 
 
<apex:page controller="SalesforceProjectsGanntController" lightningStylesheets="true">

        <html>
            <head>
                <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
                <style>
                body{
              background: rgb(113,184,222);
              background: linear-gradient(180deg, rgba(113,184,222,1) 0%, rgba(255,255,255,0.3200630594034489) 25%);
              background-repeat: no-repeat;
            }
                </style>
               </head>
            <body>
                <apex:includeScript id="a" value="https://www.google.com/jsapi" />
    			<apex:sectionHeader title="Salesforce Projects" subtitle="Delivery Timeline: Current Financial Year" />
        		<Apex:Form >
                        <apex:commandButton style="color: #0037b1; border: 1px solid #b2b2b2;margin-bottom:10px;" action="{!NYsProjects}" value="View Next Years Projects" id="theButton3"/>
            			<apex:commandButton style="color: #0037b1; border: 1px solid #b2b2b2;margin-bottom:10px;float:right;" action="{!RefreshOnProjects}" value="Refresh Timeline" id="theButton"/>
                    	<apex:commandButton style="color: #0037b1; border: 1px solid #b2b2b2;margin-bottom:10px;float:right;" action="{!ViewJobs}" value="View Jobs" id="theButton2"/>
                    
                
                    <div id="chart_div" style="width:99%;margin-left:0;margin-right:auto;"></div>
               </Apex:Form>
                 
                
                <script type="text/javascript">
                    google.charts.load('current', {'packages':['gantt']});
                google.charts.setOnLoadCallback(drawChart);
                function daysToMilliseconds(days) {
                    return days * 24 * 60 * 60 * 1000;
                }
                
                var Name = '{!Name}';
                Name = Name.replace("[","");
                Name = Name.replace("]","");
                var NameArr=Name.split(',');
                
                var startDate = '{!SDate}';
                startDate = startDate.replace("[","");
                startDate = startDate.replace("]","");
                var startDateArr=startDate.split(',');
                
                var endDate = '{!EDate}';
                endDate = endDate.replace("[","");
                endDate = endDate.replace("]","");
                var endDateArr=endDate.split(',');
               
                
                var duration = '{!Duration}';
                duration = duration.replace("[","");
                duration = duration.replace("]","");
                var durationArr=duration.split(',');
                
				var PercentComplete = '{!PercentComplete}';
                PercentComplete = PercentComplete.replace("[","");
                PercentComplete = PercentComplete.replace("]","");
                var PercentCompleteArr=PercentComplete.split(',');
                
                var JobsList = '{!JobsList}';
                
                function drawChart() {
                    
                    var data = new google.visualization.DataTable();
                    data.addColumn('string', 'Project ID');
                    data.addColumn('string', 'Project Name');
                    data.addColumn('date', 'Start Date');
                    data.addColumn('date', 'End Date');
                    data.addColumn('number', 'Duration');
                    data.addColumn('number', 'Percent Complete');
                    data.addColumn('string', 'Dependencies');
                    
                    for (var i = 0; i < NameArr.length; i++) {
                        var j=i+1;
                        var sd=startDateArr[i].replace('-',',');
                        sd=sd.replace('-',',');
                        var ed=endDateArr[i].replace('-',',');
                        ed = ed.replace('-',',');
                        var pc = PercentCompleteArr[i];
                        data.addRow([NameArr[i], NameArr[i],new Date(sd), new Date(ed), daysToMilliseconds(durationArr[i]), new Number(pc),  null]);
                    } 
                    
                    var options = {
                        height: 500
                    };
                    
                    
                    var chart = new google.visualization.Gantt(document.getElementById('chart_div'));
                    
                    chart.draw(data, options);
                }
                </script>
            
            </body>
         </html>
    
</apex:page>

 
Hi all, 

I have 82% coverage on the below test class but receiving an error on line 133 of the test class: 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, Body]: [Name, Body]

When I debug the run the name and body fields both apear to have values, not sure where im going wrong? 

Any help would be greatly appreciated. Many thanks in advance
 
@isTest
public class ContractUploadTest {

      @isTest static void ContractUploadTest(){
      
       //Record Types
        Id RetailRecordType = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Retail').getRecordTypeId();
		Id RetailSubAccountRecordType = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Retail Sub-Account').getRecordTypeId();
        
        //Insert Retailer Account
        Account acc = new Account(Name = 'TestRetailer',
                                        Known_As__C = null,
                                  		RecordTypeID = RetailRecordType,
                                        company_Number__c = '00699',
                                        company_Reg_No__c = '12345678',
                                        Phone = '015165321833',
                                        type = 'Customer',
                                        website = 'www.new.com',
                                        BillingCity = 'City',
                                        BillingCountry = 'Country',
                                        BillingPostalCode = 'CH41 7ED',
                                        BillingStreet = 'Street',
                                        Corp_Business_Type__c = 'Staff Rewards- Corporate',
                                        Discount__c = '0%',
                                        Industry = 'Retail',
                                        VAT_Number__c = '000111222',
                                        Retailer_Only_Account__c = true,
                                        Immediate_Set_Up__c = true,
                                        Retail_Sector__c = 'Fashion',
                                        Lead_Source__c= 'Networking',
                                        Payment_Terms__c = '30days',
                                        Service_Fee__c = 10,
                                        Credit_Limit__c = string.valueof(10000),
                                        Sort_Code__c = '112233',
                                        Bank_Account_Number__c = '11223344',
                                        VAT_Email__c = 'test@test.com',
                                        Remittance_Email__c = 'test@test.com',
                                        Day_Working_Week_Ends__c = 'Sunday',
                                        Required_Schemes__c = '12',
                                        Approx_Redemption_s_Per_Month__c = 1000,
                                        Opportunity_Won__c = true,
                                        Sub_Account_Type__c = null,
                                        Account_Stage__c = 'Active',
                                        Partner_Status__c = 'Active',
                                        ActiveInactive_Retailer__c = false);
        
        checkRecursive.resetRunOnceFlag();
        insert acc;
        System.assert(acc.Id !=null);
		system.debug('acc inserted: ' +acc.Name);
        
        //Create Contact
        Contact c1 = new Contact(FirstName = 'Peter',
                                  LastName = 'LastName',
                                  AccountID = acc.id,
                                  email = 'test@new.com',       
                                  Phone = '01516531833');
        insert c1;    
		System.assert(c1.Id !=null);
        acc.Primary_Contact__c = c1.id;
        acc.Financial_Contact__c = c1.id;
          
        update acc;    
         
        //Create Child Account  
        Account childAcc1 = new Account(Name = acc.Name, 
                                        Known_As__c = acc.Name +': Voucher Sub-Account',
                                        RecordTypeID = RetailSubAccountRecordType,
                                        ParentId = acc.id, 
                                        company_Number__c = '00699',
                                        company_Reg_No__c = acc.company_Reg_No__c,
                                        Phone = acc.Phone,
                                        type = 'Customer',
                                        website = acc.website,
                                        BillingCity = acc.BillingCity,
                                        BillingCountry = acc.BillingCountry,
                                        BillingPostalCode = acc.BillingPostalCode,
                                        BillingStreet = acc.BillingStreet,
                                        Corp_Business_Type__c = 'Staff Rewards- Corporate',
                                        Discount__c = '0%',
                                        Industry = 'Retail',
                                        Retail_Sector__c = acc.Retail_Sector__c,
                                        Lead_Source__c= acc.Lead_Source__c,
                                        VAT_Number__c = acc.VAT_Number__c,
                                        Financial_Contact__c = acc.Financial_Contact__c,
                                        Primary_Contact__c = acc.Primary_Contact__c,
                                        Payment_Terms__c = acc.Please_confirm_payment_terms__c,
                                        Service_Fee__c = acc.Please_confirm_service_fee__c,
                                        Credit_Limit__c = string.valueof(acc.Credit_Limit_Required__c),
                                        Retailer_Only_Account__c = true,
                                        Immediate_Set_Up__c = true,
                                        Sort_Code__c = acc.Sort_Code__c,
                                        Bank_Account_Number__c = acc.Bank_Account_Number__c,
                                        VAT_Email__c = acc.VAT_Email__c,
                                        Remittance_Email__c = acc.Remittance_Email__c,
                                        Day_Working_Week_Ends__c = acc.Day_Working_Week_Ends__c,
                                        Required_Schemes__c = acc.Required_Schemes__c,
                                        MerchantID_s__c = acc.MerchantID_s__c,
                                        Sub_Account_Type__c = 'Voucher',
                                        Approx_Redemption_s_Per_Month__c = acc.Approx_Redemption_s_Per_Month__c,
                                        Partner_Status__c = acc.Partner_Status__c);
        
      insert childAcc1;
      System.assert(childAcc1.Id !=null);    
      
      //Create Contract Record    
      Contract__c c = new Contract__c(Name = 'test',
                                       Service_Fee__c = 10,
                                       Type_Of_Contract__c = 'Voucher',
                                       Contract_Term__c = 'fixed',
                                       Start_Date__c = system.today(),
                                       Retailer__c = acc.id,
                                       Invoicing_Account__c = childAcc1.id);
      insert c;
	  System.assert(c.Id !=null);
      
 	  
        ApexPages.currentPage().getParameters().put('id', c.Id);
		ApexPages.StandardController Contract = new ApexPages.StandardController(c);
	    attachmentUpload controller = new attachmentUpload(Contract);
          
        Test.startTest();
          
        Attachment attach = new Attachment();     
                attach.Name='Unit Test Attachment';
                Blob bodyBlob =Blob.valueOf('Unit Test Attachment Body');
                attach.body = bodyBlob;
                attach.parentId = c.id;
          
          insert attach;
          system.debug('******attachment: ' +attach);
        
        controller.getmyfile();
        controller.Savedoc();
          
        Test.stopTest();

      List<Attachment> attachments = [SELECT ID, Name FROM Attachment WHERE parent.id= :c.id];
      System.assertEquals(1, attachments.size());
    }


}

 
Hi All, 

Many thanks in advance for reading.

I have a class that works as expected on single record updates but when it fires on mass inserts or updates it assigns the same value accross each batch... 

the code block is finding the previous order record and assigning the dispatch date of the previous record to the current record (so we can then calculate time between orders, etc.)

I beleive the issue is in the LastOrder list and that its assigning the same value to all records in each batch but I'm unsure of the solution in the code block and would really appreicate some assistance? 

Many thanks 
 
public class OrderTriggerHandler {
    
    public static void OrderName(List<Order__c> orderlist){
    
    Id AccId;
    Date DisDate;
        
        for(Order__c a:orderlist) {
            AccId = a.Account__c;
            DisDate = a.Dispatch_Date__c;
            System.debug('AccId: ' + AccId);
            System.debug('DisDate: ' + DisDate);
        }
        
    	List<Order__c> LastOrder = [Select Id,Dispatch_Date__c,Account__c From Order__c 
                                Where Account__c =: AccId AND Dispatch_Date__c <: DisDate 
                                Order By Dispatch_Date__c DESC 
                                LIMIT 1];
        System.debug('LastOrder List Size: ' + LastOrder.size());
        
        For(Order__c ol : orderlist){
        For(Order__c o : LastOrder ){
            ol.Previous_Order_Date__c = o.Dispatch_Date__c;
                System.debug('Previous_Order_Date__c: ' + ol.Previous_Order_Date__c);
                System.debug('Dispatch_Date__c: ' + o.Dispatch_Date__c);
        
        }
     }

 
Hi all, 

Many thanks in advance for reading. 

Im struggling to create a test class for this custom controller. i'm only getting 12% coverage so im clearly doing something fundamentally wrong but with limited experience with custom controllers i'd really appreciate any help? 

Again, much appreciation!

CONTROLLER
public class AddMultipleLinesQuoteController {
    
    Opportunity opportunity;
    ABS_Product__c ABSProduct;
    Quote_Custom__C  quote;
    Quote_Line__c qLine;
    public Integer rowIndex {get;set;}
    
    public Opportunity getOpportunity() {
        if(Opportunity == null) 
            Opportunity = [select id, name, AccountId,ownerID from Opportunity 
                           where id = :ApexPages.currentPage().getParameters().get('id')];
        return Opportunity;
    }
    
    public Quote_Custom__C getquote() {
        if(quote == null) quote = new Quote_Custom__C();
        return quote;
    }
    
	public Quote_Line__c getqLine() {
        if(qLine == null) 
            qLine = [select id,name,Discount__c,ABS_Product__c,Denomination__c, Line_Total__c,Quantity__c,Quote__c
                     from Quote_Line__c];
        return qLine;
    }
    
    public ABS_Product__c getABSProduct() {
        if(ABSProduct == null) 
            ABSProduct = [select id, name from ABS_Product__c];
        return ABSProduct;
    }
    
    Quote_Line__c line = new Quote_Line__c();
    public list<Quote_Line__c> listlines{ get; set; }
    
    public AddMultipleLinesQuoteController() {
        listlines = new list<Quote_Line__c>();
        listlines.add(line);
    }

    Public void addline() {
        Quote_Line__c l = new Quote_Line__c();
        listlines.add(l);
    }
    
    public PageReference deleteRow(){
        rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        listlines.remove(rowIndex);
        return null;
    }
    
    public PageReference saveline() {  
        
        if (line.ABS_Product__c == null ||
           line.Denomination__c == null ||
           line.Quantity__c == null ||
           line.Discount__c == null)
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please ensure all quote lines are populated'));
    	return null;
		} 
        
        if ( (Quote.Delivery_Address_Line_1__c != NULL ||
           Quote.Delivery_Address_City__c != NULL ||
              Quote.Delivery_Address_Country__c != NULL ||
           Quote.Delivery_Address_Post_Code__c != NULL) && 
           (Quote.Delivery_Address_Line_1__c == NULL ||
           Quote.Delivery_Address_City__c == NULL ||
              Quote.Delivery_Address_Country__c == NULL ||
           Quote.Delivery_Address_Post_Code__c == NULL))
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'If you are entering a physical delivery address please ensure all fields are completed'));
    	return null;
		} 
        
        
        if ( (Quote.Delivery_Address_Line_1__c == NULL &&
           Quote.Delivery_Address_City__c == NULL &&
              Quote.Delivery_Address_Country__c == NULL &&
           Quote.Delivery_Address_Post_Code__c == NULL) &&
            (Quote.Digital_Delivery_Name__c == null &&
            Quote.Digital_Delivery_Email__c == null))
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter either a physical delivery address or a digital delivery address'));
    	return null;
		} 
        
        if ( (Quote.Digital_Delivery_Name__c != null ||
            Quote.Digital_Delivery_Email__c != null) && 
            (Quote.Digital_Delivery_Name__c == null ||
            Quote.Digital_Delivery_Email__c == null))
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'If you are entering a digital delivery address please ensure both fields are completed'));
    	return null;
		}
 
        if(line.Quote__c == null){
        quote.Opportunity__c = Opportunity.id;
        insert quote;
        List<Quote_Line__c> con = new List<Quote_Line__c>();
        for(Quote_Line__c c : listlines){
            c.quote__c = quote.id;
            con.add(c);
        }
        
            insert con;
            system.debug('listLines inserted');
          
        }
        
        PageReference quotePage = new ApexPages.StandardController(new Quote_Custom__c(id=quote.Id)).view();
        quotePage.setRedirect(true);
        
        return quotePage;
        
    }   
}

CURRENT TEST CLASS
@IsTest
public class MultipleLinesQuoteControllerTest {
    
    private static testmethod void testMultipleLinesQuoteController(){
                
        
        Account acc = new Account();
        	acc.Phone = '01516531700';
        	acc.name = 'testAcc';
        	acc.type = 'Customer';
        	acc.website = 'www.parkgroup.com';
        	acc.BillingCity = 'Park House';
        	acc.BillingCountry = 'Park House';
        	acc.BillingPostalCode = 'NW10 6AJ';
        	acc.BillingStreet = 'Street';
        	acc.Corp_Business_Type__c = 'Staff Rewards- Corporate';
        	acc.Discount__c ='0%';
        	acc.Industry = 'Finance';
        	acc.Lead_Source__c='existing';
        insert acc;
        
        Opportunity opp = new Opportunity();
        	opp.name = 'test opp';
        	opp.AccountId = acc.id;
        	opp.amount = decimal.valueOf(1000);
            opp.First_Order_Value__c = decimal.valueOf(1000);
            opp.closeDate = date.today();
            opp.type = 'New Business';
        	opp.StageName = 'Qualified';
        insert opp;

        AddMultipleLinesQuoteController controller = new AddMultipleLinesQuoteController(); 
        
        Opportunity o = controller.getOpportunity();
  			PageReference pageRef = Page.quoteinput; 
  			pageRef.getParameters().put('id', String.valueOf(opp.Id));
  			Test.setCurrentPage(pageRef);
        
        
        ABS_Product__c prod = controller.getABSProduct();
        	prod.name = 'Love2shop Gift Card';
                
        Quote_Custom__c qu = controller.getQuote();
        	qu.Delivery_Address_Line_1__c = 'street';
            qu.Delivery_Address_City__c = 'city';
            qu.Delivery_Address_Country__c ='country';
            qu.Delivery_Address_Post_Code__c = 'l1 1aa';
            qu.Quote_PO_Reference__c = 'po';
            qu.Quote_Detail_Notes__c = 'details';
            qu.Opportunity__c = opp.id;
        
        Quote_Line__c quLine = controller.getqLine();
        	quLine.Discount__c = decimal.valueOf(1);
            quLine.ABS_Product__c = prod.id;
            quLine.Denomination__c = decimal.valueOf(10);
            quLine.Quantity__c = decimal.valueOf(1);
            quLine.Quote__c = qu.id;
        
        
        Quote_Line__c quLine2 = controller.getqLine();
        	quLine2.Discount__c = decimal.valueOf(1);
            quLine2.ABS_Product__c = prod.id;
            quLine2.Denomination__c = decimal.valueOf(10);
            quLine2.Quantity__c = decimal.valueOf(1);
            quLine2.Quote__c = qu.id;
        
        
        controller.addline();
        controller.deleteRow();
        controller.saveline();
        
        
    }
}

VISUALFORCE PAGE
<apex:page Controller="AddMultipleLinesQuoteController" lightningStylesheets="true" sidebar="false" >
    
    <head>
            <style type="text/css" media="print">
    
				.title {
                font-size: 12px;
                font-weight: bold;
                color: #5670ab;
                }  
                
        </style>
    </head>
    
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageMessages ></apex:pageMessages>
            <apex:pageBlockSection title="Quote Details">
                <apex:inputField value="{!opportunity.Name}"/>
                <apex:inputField value="{!Quote.Quote_PO_Reference__c}" required="true"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Delivery Details" columns="2">
                <apex:outputtext style="font-size: 14px;font-weight: bold;color: #5670ab;" value="Address for physical delivery:"/><br/>

                    <apex:inputField value="{!Quote.Delivery_Address_Line_1__c}"/><br/>
                    <apex:inputField value="{!Quote.Delivery_Address_City__c}" /><br/>
                    <apex:inputField value="{!Quote.Delivery_Address_Post_Code__c}"/><br/>
                    <apex:inputField value="{!Quote.Delivery_Address_Country__c}"/><br/>
                    <apex:outputtext style="font-size: 14px;font-weight: bold;color: #5670ab;" value="Address for digital delivery:"/><br/>
                    <apex:inputField value="{!Quote.Digital_Delivery_Name__c}"/>
                    <apex:inputField value="{!Quote.Digital_Delivery_Email__c}"/>
            </apex:pageBlockSection>
<br/>
             <apex:outputtext style="font-size: 14px;font-weight: bold;color: #5670ab; text-align: center;" value="Please detail the quote lines below, totals will be generated on the quote pdf:"/><br/>
            <br/>
            <apex:variable var="rowNumber" value="{!0}"/> 
            <apex:pageBlockTable value="{!listlines}" var="l">
                <apex:param value="{!rowNumber+1}"/>
                
                <apex:column headerValue="Item">
                    <apex:inputField value="{!l.ABS_Product__c}" />
                </apex:column>
                <apex:column headerValue="Denomination/Value" style="width: 40%;">
                    <apex:inputField value="{!l.Denomination__c}" />
                </apex:column>
                <apex:column headerValue="Quantity" style="width: 40%;">
                    <apex:inputField value="{!l.Quantity__c}" />
                </apex:column>
                <apex:column headerValue="Discount" style="width: 40%;">
                    <apex:inputField value="{!l.Discount__c}" />
                </apex:column>
                <apex:column >
                    <apex:commandButton value="X" action="{!deleteRow}" reRender="pb" style="font-weight:bold; color: red;">
                        <apex:param name="rowIndex" value="{!rowNumber}"/>
                    </apex:commandButton>
                    <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockSection title="Details/Notes" columns="1"  >
                <apex:inputField label="" style="width: 100%; align: center;" value="{!quote.Quote_Detail_Notes__c}"/>
            </apex:pageBlockSection>                
            <apex:pageBlockButtons location="Bottom" >
                <apex:commandButton value="Add New Row" action="{!addline}"/>
                <apex:commandButton value="Generate Quote" action="{!saveline}"/>
            </apex:pageBlockButtons>
            <apex:pageMessages ></apex:pageMessages>
        </apex:pageBlock>
    </apex:form>
</apex:page>

​​​​​​​
 
Hi all, 

Is there a way to remove the whitespace around a visualforce page when you add to a lightning page? 

I've tried everything with css on the page and dont feel thats it (more than willing to be proved wrong through!) but completely out of ideas...

Many thanks in advance,

Stay safe! 

screenshot
public class ProjectGanttXChart {
	public List<String> Name{get;set;}
    public List<String> SDate{get;set;}
    public List<String> EDate{get;set;}
    public List<Integer> Duration{get;set;}
    public List<String> Project{get;set;}
    
    public ProjectGanttXChart(){
        List<Case> caseList = new List<Case>();
        Name = new List<String>();
        SDate = new List<String>();
        EDate = new List<String>();
        Duration = new List<Integer>();
        Project = new List<String>();
        
        Integer dd;
        Integer month;
        Integer year;
        
        caseList = [SELECT Id, Project_Name__c, CreatedDate, Status, Start_Date__c, Completion_Date__c FROM Case WHERE Is_Project__c = true];     
        for(Case c:caseList){
            Date todayDate = c.Start_Date__c;
            dd = todayDate.day();
            month=todayDate.month();
            year = todayDate.year();
            Name.add(c.Project_Name__c);
            SDate.add(year+'-'+month+'-'+dd);
            dd = c.Completion_Date__c.day();
            month= c.Completion_Date__c.month();
            year = c.Completion_Date__c.year();
            EDate.add(year+'-'+month+'-'+dd);
            Integer dt = (c.Start_Date__c).daysBetween(Date.valueOf(c.Completion_Date__c));
            Duration.add(dt);
        }
    }
}

Hi, thanks for looking over my question, much appreicated! 

I am having trouble creating a test class for this custom controller to a visualforce page (to present a gantt chart) so I would be very greatfull for any assistance as I need to deploy to prod asap. 

Many thanks
Pete


 
Hi All, 

Any help on the below would be much appreciated.

have the below trigger and its working perfectly in the sandbox but after deploying to prod I am getting a CPU time limit exeeded failure... 

trigger ProfileTrigger on User (before insert, before update) {
    List<Id> userIds = new List<Id>();
    List<Case> cases = new List<Case>();
    List<Case> casesToUpdate = new List<Case>();
    for(User u: Trigger.new) {
        if(u.out_of_office__c==True) {
            userIds.add(u.Id);
        }
        for (case c : (cases = [SELECT id, Status FROM Case where ownerId IN:userIds]))
            IF(c.Status == 'Assigned' || c.Status == 'Working' ||c.Status == 'Escalated'){
            c.Reassign_to_Queue__c=true;
            casesToUpdate.add(c);
        }
        update casesToUpdate;
    }

Many thanks in advance! 
Pete
Hi, firstly thanks for reading! 

I'm hoping someone can help - I need a trigger to update all cases owned by a user (to queue 'Aftersales') when a checkbox = true on a user profile (out_of_office__c). 

Any help would be greatly appreciated! 

Many thanks in advance 

 
Hi, 

I have a requirement to route cases (by record type) via omni channel to agents based on their presence status. 

e.g. We have a number of agents that work in multiple areas of the support teams depending on workload and seasonality. So an agent may be working on 1 type of case in the AM and a different type in the PM, or from one day to the next etc. 

If we have 2 online presence status' (e.g. 'Available for orders cases' and 'Available for service cases') is there a way we can we route different case types to the agents based on these presence status' so they can swap between work functions as and when required?

Many thanks in advance!
Pete 

 
Hi all, 

I have 82% coverage on the below test class but receiving an error on line 133 of the test class: 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, Body]: [Name, Body]

When I debug the run the name and body fields both apear to have values, not sure where im going wrong? 

Any help would be greatly appreciated. Many thanks in advance
 
@isTest
public class ContractUploadTest {

      @isTest static void ContractUploadTest(){
      
       //Record Types
        Id RetailRecordType = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Retail').getRecordTypeId();
		Id RetailSubAccountRecordType = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Retail Sub-Account').getRecordTypeId();
        
        //Insert Retailer Account
        Account acc = new Account(Name = 'TestRetailer',
                                        Known_As__C = null,
                                  		RecordTypeID = RetailRecordType,
                                        company_Number__c = '00699',
                                        company_Reg_No__c = '12345678',
                                        Phone = '015165321833',
                                        type = 'Customer',
                                        website = 'www.new.com',
                                        BillingCity = 'City',
                                        BillingCountry = 'Country',
                                        BillingPostalCode = 'CH41 7ED',
                                        BillingStreet = 'Street',
                                        Corp_Business_Type__c = 'Staff Rewards- Corporate',
                                        Discount__c = '0%',
                                        Industry = 'Retail',
                                        VAT_Number__c = '000111222',
                                        Retailer_Only_Account__c = true,
                                        Immediate_Set_Up__c = true,
                                        Retail_Sector__c = 'Fashion',
                                        Lead_Source__c= 'Networking',
                                        Payment_Terms__c = '30days',
                                        Service_Fee__c = 10,
                                        Credit_Limit__c = string.valueof(10000),
                                        Sort_Code__c = '112233',
                                        Bank_Account_Number__c = '11223344',
                                        VAT_Email__c = 'test@test.com',
                                        Remittance_Email__c = 'test@test.com',
                                        Day_Working_Week_Ends__c = 'Sunday',
                                        Required_Schemes__c = '12',
                                        Approx_Redemption_s_Per_Month__c = 1000,
                                        Opportunity_Won__c = true,
                                        Sub_Account_Type__c = null,
                                        Account_Stage__c = 'Active',
                                        Partner_Status__c = 'Active',
                                        ActiveInactive_Retailer__c = false);
        
        checkRecursive.resetRunOnceFlag();
        insert acc;
        System.assert(acc.Id !=null);
		system.debug('acc inserted: ' +acc.Name);
        
        //Create Contact
        Contact c1 = new Contact(FirstName = 'Peter',
                                  LastName = 'LastName',
                                  AccountID = acc.id,
                                  email = 'test@new.com',       
                                  Phone = '01516531833');
        insert c1;    
		System.assert(c1.Id !=null);
        acc.Primary_Contact__c = c1.id;
        acc.Financial_Contact__c = c1.id;
          
        update acc;    
         
        //Create Child Account  
        Account childAcc1 = new Account(Name = acc.Name, 
                                        Known_As__c = acc.Name +': Voucher Sub-Account',
                                        RecordTypeID = RetailSubAccountRecordType,
                                        ParentId = acc.id, 
                                        company_Number__c = '00699',
                                        company_Reg_No__c = acc.company_Reg_No__c,
                                        Phone = acc.Phone,
                                        type = 'Customer',
                                        website = acc.website,
                                        BillingCity = acc.BillingCity,
                                        BillingCountry = acc.BillingCountry,
                                        BillingPostalCode = acc.BillingPostalCode,
                                        BillingStreet = acc.BillingStreet,
                                        Corp_Business_Type__c = 'Staff Rewards- Corporate',
                                        Discount__c = '0%',
                                        Industry = 'Retail',
                                        Retail_Sector__c = acc.Retail_Sector__c,
                                        Lead_Source__c= acc.Lead_Source__c,
                                        VAT_Number__c = acc.VAT_Number__c,
                                        Financial_Contact__c = acc.Financial_Contact__c,
                                        Primary_Contact__c = acc.Primary_Contact__c,
                                        Payment_Terms__c = acc.Please_confirm_payment_terms__c,
                                        Service_Fee__c = acc.Please_confirm_service_fee__c,
                                        Credit_Limit__c = string.valueof(acc.Credit_Limit_Required__c),
                                        Retailer_Only_Account__c = true,
                                        Immediate_Set_Up__c = true,
                                        Sort_Code__c = acc.Sort_Code__c,
                                        Bank_Account_Number__c = acc.Bank_Account_Number__c,
                                        VAT_Email__c = acc.VAT_Email__c,
                                        Remittance_Email__c = acc.Remittance_Email__c,
                                        Day_Working_Week_Ends__c = acc.Day_Working_Week_Ends__c,
                                        Required_Schemes__c = acc.Required_Schemes__c,
                                        MerchantID_s__c = acc.MerchantID_s__c,
                                        Sub_Account_Type__c = 'Voucher',
                                        Approx_Redemption_s_Per_Month__c = acc.Approx_Redemption_s_Per_Month__c,
                                        Partner_Status__c = acc.Partner_Status__c);
        
      insert childAcc1;
      System.assert(childAcc1.Id !=null);    
      
      //Create Contract Record    
      Contract__c c = new Contract__c(Name = 'test',
                                       Service_Fee__c = 10,
                                       Type_Of_Contract__c = 'Voucher',
                                       Contract_Term__c = 'fixed',
                                       Start_Date__c = system.today(),
                                       Retailer__c = acc.id,
                                       Invoicing_Account__c = childAcc1.id);
      insert c;
	  System.assert(c.Id !=null);
      
 	  
        ApexPages.currentPage().getParameters().put('id', c.Id);
		ApexPages.StandardController Contract = new ApexPages.StandardController(c);
	    attachmentUpload controller = new attachmentUpload(Contract);
          
        Test.startTest();
          
        Attachment attach = new Attachment();     
                attach.Name='Unit Test Attachment';
                Blob bodyBlob =Blob.valueOf('Unit Test Attachment Body');
                attach.body = bodyBlob;
                attach.parentId = c.id;
          
          insert attach;
          system.debug('******attachment: ' +attach);
        
        controller.getmyfile();
        controller.Savedoc();
          
        Test.stopTest();

      List<Attachment> attachments = [SELECT ID, Name FROM Attachment WHERE parent.id= :c.id];
      System.assertEquals(1, attachments.size());
    }


}

 
Hi all,

I am unfortunately unable to make a fifth column visible in a Related List - Single component on a Lightning Record Page. This is about showing Cases from a Parent Account.
I tried changing the type of the related list as 'Enhanced list', but this doesn't change anything. I still see only 4 fields and their values in the component.
Does anybody know, if it is possible to show more than 4 fields/columns in a Related List - Single component?
Hi All, 

Many thanks in advance for reading.

I have a class that works as expected on single record updates but when it fires on mass inserts or updates it assigns the same value accross each batch... 

the code block is finding the previous order record and assigning the dispatch date of the previous record to the current record (so we can then calculate time between orders, etc.)

I beleive the issue is in the LastOrder list and that its assigning the same value to all records in each batch but I'm unsure of the solution in the code block and would really appreicate some assistance? 

Many thanks 
 
public class OrderTriggerHandler {
    
    public static void OrderName(List<Order__c> orderlist){
    
    Id AccId;
    Date DisDate;
        
        for(Order__c a:orderlist) {
            AccId = a.Account__c;
            DisDate = a.Dispatch_Date__c;
            System.debug('AccId: ' + AccId);
            System.debug('DisDate: ' + DisDate);
        }
        
    	List<Order__c> LastOrder = [Select Id,Dispatch_Date__c,Account__c From Order__c 
                                Where Account__c =: AccId AND Dispatch_Date__c <: DisDate 
                                Order By Dispatch_Date__c DESC 
                                LIMIT 1];
        System.debug('LastOrder List Size: ' + LastOrder.size());
        
        For(Order__c ol : orderlist){
        For(Order__c o : LastOrder ){
            ol.Previous_Order_Date__c = o.Dispatch_Date__c;
                System.debug('Previous_Order_Date__c: ' + ol.Previous_Order_Date__c);
                System.debug('Dispatch_Date__c: ' + o.Dispatch_Date__c);
        
        }
     }

 
Hi all, 

Many thanks in advance for reading. 

Im struggling to create a test class for this custom controller. i'm only getting 12% coverage so im clearly doing something fundamentally wrong but with limited experience with custom controllers i'd really appreciate any help? 

Again, much appreciation!

CONTROLLER
public class AddMultipleLinesQuoteController {
    
    Opportunity opportunity;
    ABS_Product__c ABSProduct;
    Quote_Custom__C  quote;
    Quote_Line__c qLine;
    public Integer rowIndex {get;set;}
    
    public Opportunity getOpportunity() {
        if(Opportunity == null) 
            Opportunity = [select id, name, AccountId,ownerID from Opportunity 
                           where id = :ApexPages.currentPage().getParameters().get('id')];
        return Opportunity;
    }
    
    public Quote_Custom__C getquote() {
        if(quote == null) quote = new Quote_Custom__C();
        return quote;
    }
    
	public Quote_Line__c getqLine() {
        if(qLine == null) 
            qLine = [select id,name,Discount__c,ABS_Product__c,Denomination__c, Line_Total__c,Quantity__c,Quote__c
                     from Quote_Line__c];
        return qLine;
    }
    
    public ABS_Product__c getABSProduct() {
        if(ABSProduct == null) 
            ABSProduct = [select id, name from ABS_Product__c];
        return ABSProduct;
    }
    
    Quote_Line__c line = new Quote_Line__c();
    public list<Quote_Line__c> listlines{ get; set; }
    
    public AddMultipleLinesQuoteController() {
        listlines = new list<Quote_Line__c>();
        listlines.add(line);
    }

    Public void addline() {
        Quote_Line__c l = new Quote_Line__c();
        listlines.add(l);
    }
    
    public PageReference deleteRow(){
        rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        listlines.remove(rowIndex);
        return null;
    }
    
    public PageReference saveline() {  
        
        if (line.ABS_Product__c == null ||
           line.Denomination__c == null ||
           line.Quantity__c == null ||
           line.Discount__c == null)
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please ensure all quote lines are populated'));
    	return null;
		} 
        
        if ( (Quote.Delivery_Address_Line_1__c != NULL ||
           Quote.Delivery_Address_City__c != NULL ||
              Quote.Delivery_Address_Country__c != NULL ||
           Quote.Delivery_Address_Post_Code__c != NULL) && 
           (Quote.Delivery_Address_Line_1__c == NULL ||
           Quote.Delivery_Address_City__c == NULL ||
              Quote.Delivery_Address_Country__c == NULL ||
           Quote.Delivery_Address_Post_Code__c == NULL))
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'If you are entering a physical delivery address please ensure all fields are completed'));
    	return null;
		} 
        
        
        if ( (Quote.Delivery_Address_Line_1__c == NULL &&
           Quote.Delivery_Address_City__c == NULL &&
              Quote.Delivery_Address_Country__c == NULL &&
           Quote.Delivery_Address_Post_Code__c == NULL) &&
            (Quote.Digital_Delivery_Name__c == null &&
            Quote.Digital_Delivery_Email__c == null))
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter either a physical delivery address or a digital delivery address'));
    	return null;
		} 
        
        if ( (Quote.Digital_Delivery_Name__c != null ||
            Quote.Digital_Delivery_Email__c != null) && 
            (Quote.Digital_Delivery_Name__c == null ||
            Quote.Digital_Delivery_Email__c == null))
		{
    	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'If you are entering a digital delivery address please ensure both fields are completed'));
    	return null;
		}
 
        if(line.Quote__c == null){
        quote.Opportunity__c = Opportunity.id;
        insert quote;
        List<Quote_Line__c> con = new List<Quote_Line__c>();
        for(Quote_Line__c c : listlines){
            c.quote__c = quote.id;
            con.add(c);
        }
        
            insert con;
            system.debug('listLines inserted');
          
        }
        
        PageReference quotePage = new ApexPages.StandardController(new Quote_Custom__c(id=quote.Id)).view();
        quotePage.setRedirect(true);
        
        return quotePage;
        
    }   
}

CURRENT TEST CLASS
@IsTest
public class MultipleLinesQuoteControllerTest {
    
    private static testmethod void testMultipleLinesQuoteController(){
                
        
        Account acc = new Account();
        	acc.Phone = '01516531700';
        	acc.name = 'testAcc';
        	acc.type = 'Customer';
        	acc.website = 'www.parkgroup.com';
        	acc.BillingCity = 'Park House';
        	acc.BillingCountry = 'Park House';
        	acc.BillingPostalCode = 'NW10 6AJ';
        	acc.BillingStreet = 'Street';
        	acc.Corp_Business_Type__c = 'Staff Rewards- Corporate';
        	acc.Discount__c ='0%';
        	acc.Industry = 'Finance';
        	acc.Lead_Source__c='existing';
        insert acc;
        
        Opportunity opp = new Opportunity();
        	opp.name = 'test opp';
        	opp.AccountId = acc.id;
        	opp.amount = decimal.valueOf(1000);
            opp.First_Order_Value__c = decimal.valueOf(1000);
            opp.closeDate = date.today();
            opp.type = 'New Business';
        	opp.StageName = 'Qualified';
        insert opp;

        AddMultipleLinesQuoteController controller = new AddMultipleLinesQuoteController(); 
        
        Opportunity o = controller.getOpportunity();
  			PageReference pageRef = Page.quoteinput; 
  			pageRef.getParameters().put('id', String.valueOf(opp.Id));
  			Test.setCurrentPage(pageRef);
        
        
        ABS_Product__c prod = controller.getABSProduct();
        	prod.name = 'Love2shop Gift Card';
                
        Quote_Custom__c qu = controller.getQuote();
        	qu.Delivery_Address_Line_1__c = 'street';
            qu.Delivery_Address_City__c = 'city';
            qu.Delivery_Address_Country__c ='country';
            qu.Delivery_Address_Post_Code__c = 'l1 1aa';
            qu.Quote_PO_Reference__c = 'po';
            qu.Quote_Detail_Notes__c = 'details';
            qu.Opportunity__c = opp.id;
        
        Quote_Line__c quLine = controller.getqLine();
        	quLine.Discount__c = decimal.valueOf(1);
            quLine.ABS_Product__c = prod.id;
            quLine.Denomination__c = decimal.valueOf(10);
            quLine.Quantity__c = decimal.valueOf(1);
            quLine.Quote__c = qu.id;
        
        
        Quote_Line__c quLine2 = controller.getqLine();
        	quLine2.Discount__c = decimal.valueOf(1);
            quLine2.ABS_Product__c = prod.id;
            quLine2.Denomination__c = decimal.valueOf(10);
            quLine2.Quantity__c = decimal.valueOf(1);
            quLine2.Quote__c = qu.id;
        
        
        controller.addline();
        controller.deleteRow();
        controller.saveline();
        
        
    }
}

VISUALFORCE PAGE
<apex:page Controller="AddMultipleLinesQuoteController" lightningStylesheets="true" sidebar="false" >
    
    <head>
            <style type="text/css" media="print">
    
				.title {
                font-size: 12px;
                font-weight: bold;
                color: #5670ab;
                }  
                
        </style>
    </head>
    
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageMessages ></apex:pageMessages>
            <apex:pageBlockSection title="Quote Details">
                <apex:inputField value="{!opportunity.Name}"/>
                <apex:inputField value="{!Quote.Quote_PO_Reference__c}" required="true"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Delivery Details" columns="2">
                <apex:outputtext style="font-size: 14px;font-weight: bold;color: #5670ab;" value="Address for physical delivery:"/><br/>

                    <apex:inputField value="{!Quote.Delivery_Address_Line_1__c}"/><br/>
                    <apex:inputField value="{!Quote.Delivery_Address_City__c}" /><br/>
                    <apex:inputField value="{!Quote.Delivery_Address_Post_Code__c}"/><br/>
                    <apex:inputField value="{!Quote.Delivery_Address_Country__c}"/><br/>
                    <apex:outputtext style="font-size: 14px;font-weight: bold;color: #5670ab;" value="Address for digital delivery:"/><br/>
                    <apex:inputField value="{!Quote.Digital_Delivery_Name__c}"/>
                    <apex:inputField value="{!Quote.Digital_Delivery_Email__c}"/>
            </apex:pageBlockSection>
<br/>
             <apex:outputtext style="font-size: 14px;font-weight: bold;color: #5670ab; text-align: center;" value="Please detail the quote lines below, totals will be generated on the quote pdf:"/><br/>
            <br/>
            <apex:variable var="rowNumber" value="{!0}"/> 
            <apex:pageBlockTable value="{!listlines}" var="l">
                <apex:param value="{!rowNumber+1}"/>
                
                <apex:column headerValue="Item">
                    <apex:inputField value="{!l.ABS_Product__c}" />
                </apex:column>
                <apex:column headerValue="Denomination/Value" style="width: 40%;">
                    <apex:inputField value="{!l.Denomination__c}" />
                </apex:column>
                <apex:column headerValue="Quantity" style="width: 40%;">
                    <apex:inputField value="{!l.Quantity__c}" />
                </apex:column>
                <apex:column headerValue="Discount" style="width: 40%;">
                    <apex:inputField value="{!l.Discount__c}" />
                </apex:column>
                <apex:column >
                    <apex:commandButton value="X" action="{!deleteRow}" reRender="pb" style="font-weight:bold; color: red;">
                        <apex:param name="rowIndex" value="{!rowNumber}"/>
                    </apex:commandButton>
                    <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockSection title="Details/Notes" columns="1"  >
                <apex:inputField label="" style="width: 100%; align: center;" value="{!quote.Quote_Detail_Notes__c}"/>
            </apex:pageBlockSection>                
            <apex:pageBlockButtons location="Bottom" >
                <apex:commandButton value="Add New Row" action="{!addline}"/>
                <apex:commandButton value="Generate Quote" action="{!saveline}"/>
            </apex:pageBlockButtons>
            <apex:pageMessages ></apex:pageMessages>
        </apex:pageBlock>
    </apex:form>
</apex:page>

​​​​​​​
 
Hi all, 

Is there a way to remove the whitespace around a visualforce page when you add to a lightning page? 

I've tried everything with css on the page and dont feel thats it (more than willing to be proved wrong through!) but completely out of ideas...

Many thanks in advance,

Stay safe! 

screenshot
public class ProjectGanttXChart {
	public List<String> Name{get;set;}
    public List<String> SDate{get;set;}
    public List<String> EDate{get;set;}
    public List<Integer> Duration{get;set;}
    public List<String> Project{get;set;}
    
    public ProjectGanttXChart(){
        List<Case> caseList = new List<Case>();
        Name = new List<String>();
        SDate = new List<String>();
        EDate = new List<String>();
        Duration = new List<Integer>();
        Project = new List<String>();
        
        Integer dd;
        Integer month;
        Integer year;
        
        caseList = [SELECT Id, Project_Name__c, CreatedDate, Status, Start_Date__c, Completion_Date__c FROM Case WHERE Is_Project__c = true];     
        for(Case c:caseList){
            Date todayDate = c.Start_Date__c;
            dd = todayDate.day();
            month=todayDate.month();
            year = todayDate.year();
            Name.add(c.Project_Name__c);
            SDate.add(year+'-'+month+'-'+dd);
            dd = c.Completion_Date__c.day();
            month= c.Completion_Date__c.month();
            year = c.Completion_Date__c.year();
            EDate.add(year+'-'+month+'-'+dd);
            Integer dt = (c.Start_Date__c).daysBetween(Date.valueOf(c.Completion_Date__c));
            Duration.add(dt);
        }
    }
}

Hi, thanks for looking over my question, much appreicated! 

I am having trouble creating a test class for this custom controller to a visualforce page (to present a gantt chart) so I would be very greatfull for any assistance as I need to deploy to prod asap. 

Many thanks
Pete


 
Hi All, 

Any help on the below would be much appreciated.

have the below trigger and its working perfectly in the sandbox but after deploying to prod I am getting a CPU time limit exeeded failure... 

trigger ProfileTrigger on User (before insert, before update) {
    List<Id> userIds = new List<Id>();
    List<Case> cases = new List<Case>();
    List<Case> casesToUpdate = new List<Case>();
    for(User u: Trigger.new) {
        if(u.out_of_office__c==True) {
            userIds.add(u.Id);
        }
        for (case c : (cases = [SELECT id, Status FROM Case where ownerId IN:userIds]))
            IF(c.Status == 'Assigned' || c.Status == 'Working' ||c.Status == 'Escalated'){
            c.Reassign_to_Queue__c=true;
            casesToUpdate.add(c);
        }
        update casesToUpdate;
    }

Many thanks in advance! 
Pete
Hi, firstly thanks for reading! 

I'm hoping someone can help - I need a trigger to update all cases owned by a user (to queue 'Aftersales') when a checkbox = true on a user profile (out_of_office__c). 

Any help would be greatly appreciated! 

Many thanks in advance