• Brooks Johnson 6
  • NEWBIE
  • 45 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 27
    Replies
Hi Friends I have a form that I need to write in Visualforce because it must be exportable to PDF. I  was using CSS Grid for my layout but when I switched to renderAs="PDF" my grid formatting was gone. If I add floats the PDF responds. Am I a making a mistake or does the  CSS Grid not work with the PDF? Here is my <head> 
 
<apex:page id="Region_Health_Check" showHeader="false" standardController="Region__c" docType="html-5.0"
    sideBar="false" standardStylesheets="false" renderAs="pdf">
    <head>
        <title>Region Health Check Report</title>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <apex:stylesheet value="{!$Resource.HealthCheckStyle}"/>
    </head>

CSS forgive having floats and grid in place. 
/* HealthCheckStyle */
@page{
    size: letter;
    margin: 25mm;

}

body{
    font-family:  BrownStd,serif;
    font-size: 14px;
    display: grid;
}
.top{
    display: grid;
    grid-template-columns: repeat(10, 10%);
    grid-template-rows: auto;
}
.score-label{
    grid-area: 1 / 9/ 2 / 10;
    font-size:  12px;
    float: right;
}
.engagement-label{
    grid-area:  2 / 1/  2 /4;
    font-size: 26px;
    font-weight: bold;
}
.final-grade{
    font-size: 39px;
    font-weight: bold;
    grid-area: 2/9/4/10;
    float: right;
}
.region-name{
    font-size: 24px;
    grid-area: 3/ 1/ 4/ 3;
}
hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid red;
    margin: 1em 0;
    padding: 0;
}
h4{
    font-size: 14px;
}

 
Hi Friends,

I have a requirement to find all contacts with no related tasks or if they do have a task to filter out certain types.  When I start with a base SOQL Query on the workbench I get an error that Task is not supported from Semi Join inner select.  The base query is:  

SELECT Id, Name FROM Contact WHERE Id NOT IN (SELECT WhoID FROM Task). Is there another way to do this? 
Hi Friends,

I have a method that updates a lookup field on the task object. The task field is updated based on the value in a lookup field on the Contact. I  know it is inefficient and it fails my bulk test class. But I am not sure how to optimize the SOQL query to get my code under the  100 SOQL query limit. Any tips or pointers would be great.  The tasks are getting passed into the Method through trigger.new in a trigger handler. I am sure that putting the WhoIds into a list and doing a query to get the contacts and add them to a Map is pretty sub-optimal. 
public static void assignTasksToRelationshipOwnersInsert(List<Task> taskList) {
        //assign contacts owner to task look up field
        Set<Id> contactIds = new Set<Id>();
        for (Task t : taskList) {
            if (t.WhoId != null && t.Subject.contains('Pardot List Email')) {
                contactIds.add(t.WhoId);
            }
        }
        //create a map of contacts and regions
        //Fails SOQL limit here
        List<Contact> contactList = [
                SELECT Id, New_Relationship_owner1__c
                FROM CONTACT
                WHERE Id IN:contactIds
                AND New_Relationship_owner1__c != Null
        ];
        Map<Id, ID> contactMap = new Map<Id, Id>();
        for (Contact c : contactList) {
            contactMap.put(c.Id, c.New_Relationship_owner1__c);
        }
        for (Task updatedTask : taskList) {
            if (contactMap.containsKey(updatedTask.WhoId) && contactMap.size() > 0) {
                updatedTask.Relationship_Owner__c = contactMap.get(updatedTask.WhoId);
            }
        }
    }


 
Hi Friends, 

I know null pointer errors are such a common question I hate to add another one. But I can't figure out what I am doing wrong and I am hoping I can learn something here.  I'm getting the error from my final For Loop. I thought I had checked for it with the != null in my If statement. Hoping someone can point me in the right direction.
 
public  class UniqueEmailCountHandler {
    
    public static void uniqueRelationshipOwnerEmails(List<relationship_owner__c> roList){
        //count the unique emails  that have been sent by a relationship owner
        // add all contacts associated with relationship owner to map.         
        Map<id, Contact> contactMap = new Map<Id, Contact>([SELECT Id,
                                                            New_Relationship_Owner1__c
                                                            FROM Contact
                                                            WHERE New_Relationship_owner1__c IN : roList]);
        system.debug('Number of relationship owners in trigger = ' + roList.size());
        system.debug('Contacts found = ' + contactMap.size());
        //put tasks where whoId is in the contact map into a new map
        List<Task> taskList = [SELECT Id, WhoId,Subject
                               FROM Task 
                               WHERE WhoId IN :contactMap.keySet()
                               AND Subject LIKE '%Pardot List %'];
        system.debug('Tasks Found  and added to map = ' + taskList.size());
        
        //use set to dedupe the list
        Map<Id, Set<String>> subjectLineMap = new Map<Id, Set<String>>();
        
        for(task t : taskList){
            Id ownerId = contactMap.get(t.WhoId).New_Relationship_Owner1__c;            
            if(!subjectLineMap.containsKey(ownerId)){
                subjectLineMap.put(ownerId, new Set<String>());
                system.debug('Subect Line found ' + t.Subject);              
                
            }
            Set<String> subjects = subjectLineMap.get(OwnerId);
            subjects.add(t.Subject);
            subjectLineMap.put(OwnerId, Subjects);
            
        }
        system.debug('Map size   =' + subjectLineMap.size());
        system.debug('map values =' + subjectLineMap.values());
        system.debug('map keys   =' + subjectLineMap.Keyset());
        {
            for(relationship_owner__c relationshipOwner : roList){
                if(subjectLIneMap.get(relationshipOwner.Id).size() != Null){
                relationshipOwner.Unique_Emails_Sent__c = subjectLIneMap.get(relationshipOwner.Id).size();
                }
                
            }

 
Hello Friends. 

I am hoping someone can help me with this method. I have been working on it all afternoon with no luck.  My requirement is to get to a  count of tasks that are related to contacts and place a value on a custom object. The custom object relationship_owner__C is the parent in a  look up a relationship with the Contact object. 

When a relationship_owner__C is updated then look for all contacts owned by the relationship owner with tasks that begin with the phrase "Pardot List" Evaluate the text that comes after Pardot list to determine how many unique subject lines there are. 

If the relationship owner  Test Owner has 5 contacts and Each Contact has Two Tasks with the Subject Line Pardot List 1 and Pardot List 2. The relationship owner would be updated with a  total unique value of 2.  When I test in the UI I get a value of 1 no matter how many tasks I create. And my test class for a single email fails its assertions and says 0 emails.

Here is my method.  It is called from a trigger handler on before update. 
public static void uniqueRelationshipOwnerEmails(List<relationship_owner__c> roList){
        //count the unique emails  that have been sent by a relationship owner
        // add all contacts associated with relationship owner to map.         
        Map<id, Contact> contactMap = new Map<Id, Contact>([SELECT Id,
                                                            New_Relationship_Owner1__c
                                                            FROM Contact
                                                            WHERE New_Relationship_owner1__c IN : roList]);
        system.debug('Number of relationship owners in trigger = ' + roList.size());
        system.debug('Contacts found = ' + contactMap.size());
        //put tasks where whoId is in the contact map into a new map
        List<Task> taskList = [SELECT Id, WhoId,Subject
                               FROM Task 
                               WHERE WhoId IN :contactMap.keySet()
                               AND Subject LIKE '%Pardot List %'];
        system.debug('Tasks Found  and added to map = ' + taskList.size());
        
        //use set to dedupe the list
        Map<Id, Set<String>> subjectLineMap = new Map<Id, Set<String>>();
        
        for(task t : taskList){
            Id ownerId = contactMap.get(t.WhoId).New_Relationship_Owner1__c;            
            if(!subjectLineMap.containsKey(ownerId)){
                subjectLineMap.put(ownerId, new Set<String>());
                system.debug('Subect Line found ' + t.Subject);
               
                
            }

 
I have a flow in place that counts tasks of certain types. Will these tasks still be visible to the Flow when they are archived? I will I need to write an APEX method to query them and Include All Rows? 
I am trying to write a method to get the median value on  a set of scores on the Contact object.  I have a list from the Contact object that is looking for one value from a numeric field. But I am getting an error that arithmetic expressions must use numeric arguments. I am assuming this is coming from my trying to do math with my Contact list values?
 
public class CalculateHealthMetrics {
    
    
    public static void getMedianPardotScore(){
        Decimal medianPiScore = 0;
        Integer listSize             = 0;
        Integer index               = listSize -1;
        //get all Pardot Scores in Descending Order
        List<Contact> pardotScores = [SELECT pi__score__c
                                      FROM Contact
                                      ORDER BY pi__score__c DESC];
        listSize = pardotScores.size();
        system.debug('list size =' + listSize);
        pardotScores.sort();
        if(Math.mod(listSize, 2) == 0){
            medianPiScore = (pardotScores[(index -1) / 2] + pardotScores[(index / 2) + 1]) / 2;
        }
        
        
        
    }
    
}

 
I have an auto-launched flow that is designed to look all contacts assigned to a custom object Relationship_Owner__C, get all the tasks that are related to Pardot mailings and then loop through and count unique subject lines. The good news is this flow works fine. But I have some new business cases to get these counts for other objects that also have a lookup relationship to Contact. The logic that worked fine for relationship_owner__c is failing to find records for other lookup relationships. 

The below looks ups do what I want. 
User-added imageUser-added image

The next flow, which should be almost a close is failing to find records. What am I doing wrong here?

User-added imageUser-added imageUser-added image
I am trying to build my first Lightning Component for my production Org by following along with Trailhead and modifying my code to fit the data I need from my sandbox.  My component will not display and I swear I have been over my code 100 times. Any help would be great. 

Lightning Component
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="DivisionHealthCheckController" >
    <aura:attribute name="Divisions" type="Division__c"/>
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <lightning:card title="Division Health Checks">
        <aura:set attribute="body">
        <table class="slds-table slds-table_bordered slds-table_cell-buffer">
            <thead>
               <tr class="slds-text-title_caps">
          		  <th scope="col">Division</th>
           		  <th scope="col">Grade</th>
           		  <th scope="col">Total Influencers</th>
               </tr>
            </thead>
            <tbody>
            <aura:iteration items="{!v.Divisions}" var ="div">
                <tr scope="row">
                    <td> {!div.Name}</td>
                    <td> {!div.Grade__c}</td>                
                </tr>
                 </aura:iteration>
            </tbody>               
          </table>
        </aura:set>       
    </lightning:card>	
</aura:component>

Controller
public with sharing class DivisionHealthCheckController {
    @AuraEnabled
    public static List<Division__c> divisionHealth(){
        return [SELECT Id,
               Name,
               Grade__c               
               FROM Division__c            
        ];
    }

}

JS Controller
({
	doInit : function(component, event, helper) {
        var action = component.get("c.divisionHealth");
        action.setCallback(this, function(data){
            component.set("v.Divisions", data.getReturnValue());
            console.log(data.getReturnValue());
        });
        $A.enqueueAction(action);
		
	}
})


 
trigger CountUniqueEmails on relationship_owner__c (before insert, before update) {
    for (Relationship_Owner__c   rOwner : trigger.new){
        
        //get list of on tasks belonging to owner that contain "Pardot"    
    LIST<Task> taskList = [SELECT ID,
                           Subject
                           FROM Task
                           WHERE Subject LIKE 'Pardot'
                          AND WhoId = :rOwner.Id];
        system.debug(taskList.size() + 'Matching tasks found');
        
        //if matches are found        
        if(!tasklist.isEmpty()){
            String pardotSubject = 'none';
            Integer uniqueCount = 0;
            //loop through matches and increment count if unqique
            for( Task t : taskList){
                if( pardotSubject != t.Subject){
                    uniqueCount = uniqueCount +1; 
                    system.debug('Unique count' + uniqueCount);
                }
                rOwner.Unique_Emails_Sent__c = uniqueCount;
                insert rOwner;               
                
            }            
            
        }
    } 
    
    
    //need a list of all tasks that contain pardot that belong to the relationship owner
    //Loop through tasks  to a get a count of unique subjects
    //Update Relationship Owner. 

}
trigger CountUniqueEmails on relationship_owner__c (before insert, before update) {
    for (Relationship_Owner__c   rOwner : trigger.new){
        
        //get list of on tasks belonging to owner that contain "Pardot"    
    LIST<Task> taskList = [SELECT ID,
                           Subject
                           FROM Task
                           WHERE Subject LIKE 'Pardot'
                          AND WhoId = :rOwner.Id];
        system.debug(taskList.size() + 'Matching tasks found');
        
        //if matches are found        
        if(!tasklist.isEmpty()){
            String pardotSubject = 'none';
            Integer uniqueCount = 0;
            //loop through matches and increment count if unqique
            for( Task t : taskList){
                if( pardotSubject != t.Subject){
                    uniqueCount = uniqueCount +1; 
                    system.debug('Unique count' + uniqueCount);
                }
                rOwner.Unique_Emails_Sent__c = uniqueCount;
                insert rOwner;               
                
            }            
            
        }
    } 
    
    
    //need a list of all tasks that contain pardot that belong to the relationship owner
    //Loop through tasks  to a get a count of unique subjects
    //Update Relationship Owner. 

}

 
I  am trying to update some custom meta records. There are current 4384 records in the system. And updating  gives me an error of "Collection size 4,384 exceeds maximum size of 1,000." This happens even if I try to upload fewer than 1000 records.
I tried to delete them from the Workbench and just start over. But I get an error that I have insufficient access rights on object Id.
I do not seem to have any errors in my code. But when I go to override the Edit button my Lightning Component is not visible. The dropdown reads none. Where did I go wrong?
 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name = "speaker" type = "Speaker__c" />
    <aura:attribute name = "recordId" type="String" />
    <div class = "slds-p-bottom_large slds-p-left_large" style = "width:600px">
        <lightning:recordEditForm aura:id       = "recordViewForm"
                                  recordId      = "{!v.recordId}"
                                  recordTypeId  = "{!v.speaker}"
                                  objectApiName ="Speaker__c"
                                  onSuccess     ="{!c.onSuccess}">
            <lightning:messages/>
            <lightning:inputField fieldName ="First_Name__c"/>
            <lightning:inputField fieldName = "Last_Name__c"/>
            <lightning:inputField fieldName = "Email__c" />
            <Lightning:InputField fieldName = "Bio__c" />
            <Lightning:button     aura:id   = "submit" type = "submit" label="Update Speaker" class = "slds-m-top_medium"/>
        </lightning:recordEditForm>    
    </div>	
</aura:component>
 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name = "speaker" type = "Speaker__c" />
    <aura:attribute name = "recordId" type="String" />
    <div class = "slds-p-bottom_large slds-p-left_large" style = "width:600px">
        <lightning:recordEditForm aura:id       = "recordViewForm"
                                  recordId      = "{!v.recordId}"
                                  recordTypeId  = "{!v.speaker}"
                                  objectApiName ="Speaker__c"
                                  onSuccess     ="{!c.onSuccess}">
            <lightning:messages/>
            <lightning:inputField fieldName ="First_Name__c"/>
            <lightning:inputField fieldName = "Last_Name__c"/>
            <lightning:inputField fieldName = "Email__c" />
            <Lightning:InputField fieldName = "Bio__c" />
            <Lightning:button     aura:id   = "submit" type = "submit" label="Update Speaker" class = "slds-m-top_medium"/>
        </lightning:recordEditForm>    
    </div>	
</aura:component>

 
Trying to learn to use Conga Composer. Does anyone know it is capable of changing font color based on certain conditions?  If Score > 100 then green, for example. Or would I have to put an Excel table in a Word Doc to at least change cell colors?
I am trying to comment out a couple old triggers that my Org does not use anymore. They are commented out in the Sandbox and set to inactive. I have also commented out the test classes and the trigger handlers in the sandbox. 

But I am not able to deploy because one the triggers and two of the test classes are on an object that no longer exists. I am getting a  failure because my code coverage is only 63%  The tests that are failing are the ones that I want to turn off along with their trigger. How can I deal with this?
I have a trigger that I am trying to comment out but I get an unexpected token error. I know this must be simple but where am I going wrong. 
 
/*trigger ContactTrigger on Contact (before insert, after insert, after update, before update) {
//
//Author       :   Amit SanWariya(Appirio)
//Created Date :   15 Feb' 2016
//Task         :   T-476163
//Description  :   Trigger to update the Geolocation fields on Influencer(Contact) object
//
    if(Trigger.isInsert && Trigger.isBefore){
       if(System.label.Disable_Influencer_Owner_Change == 'false'){
             list<contact> contlist = trigger.new;
             for(contact cont: contlist){
                 cont.InfluencerOwner__c = cont.ownerid;
                 cont.ownerid = System.label.NewOwnerId;
             }
       }
    }
    
    if(Trigger.isUpdate && Trigger.isBefore){
     System.debug('####### Before update cont.influencerOwner__c ');
     
       if(System.label.Disable_Influencer_Owner_Change == 'false'){
             list<contact> oldcontlist = trigger.old;
             list<contact> newcontlist = trigger.new;
             System.debug('####### Before update '+oldcontlist.size());             
             for(contact cont: newcontlist){
                 contact oldContact = Trigger.oldMap.get(cont.Id);
                 /*
                 if (cont.InfluencerOwner__c != null && cont.ownerid != cont.influencerOwner__c) {
                     cont.InfluencerOwner__c = cont.ownerid;
                     cont.ownerid = System.label.NewOwnerId;
                 }*/
                 /* if(cont.influencerOwner__c == null){
                     System.debug('####### cont.influencerOwner__c '+System.label.NewOwnerId);
                     cont.InfluencerOwner__c = cont.ownerid;
                     cont.ownerid = System.label.NewOwnerId;                 
                 }
             }
       }
        
    }
    
    if ( Trigger.isInsert && Trigger.isAfter ) {
        //ContactTriggerHandler.afterInsert( Trigger.new );
    }
    else if ( Trigger.isUpdate && Trigger.isAfter ) {
        //ContactTriggerHandler.afterUpdate( Trigger.new, Trigger.oldMap );
    }
    else if ( Trigger.isUpdate && Trigger.isBefore ) {
        //ContactTriggerHandler.beforeUpdate( Trigger.new, Trigger.oldMap );
    }
    
    if(Trigger.isAfter){
        if(checkRecursive.runOnce())
        {
            System.debug('######## Contact trigger Called ');
            System.debug('########System.Label.Disable_Interface_Flow '+System.Label.Disable_Interface_Flow);            
            if('False' == System.Label.Disable_Interface_Flow){
                 System.debug('######## Called syncCustomer code');
                SendAccountUsingRestApi.syncCustomer();
            }
            if(Trigger.isUpdate){
                if('False' == System.Label.DISABLE_PARDOT_ASSIGNMENT_CALL){
                    CustomPARDOT.assignProspectsByContact(Trigger.new);
                }
            }
         if('false' == System.Label.DISABLE_RELATIONSHIP_OWNER_SHARING){
           InfluencerSharingWithRelationshipOwner.sharewithRelationshipOwner(Trigger.new);
         }
         System.debug('::CONTACT SENT TO PARDOT::');

        }
    }
}*/

 
I am trying to build a flow that loops through all Contact Records to find the largest Pardot score. It will then save that score in a variable to use for scoring. My plan was for this to be an auto-launched flow from Process Builder. I am stuck one starting variable to use to have the Flow loop through all contacts. Not just a set belonging to a certain account or owner etc.... 
Hi I am trying to work through the Custom Controller challenge in Trailhead.  My VF page is giving me the error : 
Visualforce Error
Help for this Page
System.QueryException: unexpected token: ORDER 
Class.ContactsListController.getContacts: line 7, column 1

I am not seeing anything wrong with my code.  Any thoughts on where I am going wrong?
apex:page controller="ContactsListController">
    <apex:form >
        <apex:pageBlock title="Contacts List" id="contacts_list">
            <apex:pageBlockTable value="{! contacts}" var="ct">
                <apex:column value="{!ct.FirstName}"/>
                <apex:column value="{! ct.LastName}"/>
                <apex:column value="{! ct.Title}"/>
                <apex:column value="{! ct.Email}"/>                                                  
            
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>   
    
</apex:page>


public class ContactsListController {
    
    private String sortOrder = 'LastName';
    
    public List<Contact> getContacts(){
    
    	LIST<Contact> results = Database.query(
            'SELECT Id, FirstName, LastName, Title, Email' +
            'FROM Contact ' + 
            'ORDER BY ' + sortOrder + ' ASC ' + 
            'LIMIT 10'
        );
        return results;
    
            }
}

 
I need to build a button that links to visual force page so my users can export directly to Excel.  But I am getting errors trying to connect to the related lists. I related list is called "influencers" It is a list on a custom object called Lists. The related list are contacts that are connected via a junction object calls Relationship Owner.  Lists__c , Relationship_Owner__C and Contacts.  On Schema Builder the name of the relationship from Lists to Releionship_Owner is "lists"

If I try to access via <apex:relatedlist/> I get an error that "Contacts is not a valid child relationship name for entity list.  I get the same error if I try to use <apex:relatedlist list ="lists__r>

I have also tried to build a table that connected all three via dot notation and still can get the related list to appear.  Pretty new to Visualforce and Salesforce Development. Any help would be great. 
<apex:page standardController="Lists__c">
    <apex:pageBlock title="Influencers">    
    	<apex:pageBlockTable value="{!Lists.Lists__r.contacts}" var="contacts">        
   	    </apex:pageBlockTable>        
   </apex:pageBlock>
</apex:page>

 
Hi Friends,

I have a method that updates a lookup field on the task object. The task field is updated based on the value in a lookup field on the Contact. I  know it is inefficient and it fails my bulk test class. But I am not sure how to optimize the SOQL query to get my code under the  100 SOQL query limit. Any tips or pointers would be great.  The tasks are getting passed into the Method through trigger.new in a trigger handler. I am sure that putting the WhoIds into a list and doing a query to get the contacts and add them to a Map is pretty sub-optimal. 
public static void assignTasksToRelationshipOwnersInsert(List<Task> taskList) {
        //assign contacts owner to task look up field
        Set<Id> contactIds = new Set<Id>();
        for (Task t : taskList) {
            if (t.WhoId != null && t.Subject.contains('Pardot List Email')) {
                contactIds.add(t.WhoId);
            }
        }
        //create a map of contacts and regions
        //Fails SOQL limit here
        List<Contact> contactList = [
                SELECT Id, New_Relationship_owner1__c
                FROM CONTACT
                WHERE Id IN:contactIds
                AND New_Relationship_owner1__c != Null
        ];
        Map<Id, ID> contactMap = new Map<Id, Id>();
        for (Contact c : contactList) {
            contactMap.put(c.Id, c.New_Relationship_owner1__c);
        }
        for (Task updatedTask : taskList) {
            if (contactMap.containsKey(updatedTask.WhoId) && contactMap.size() > 0) {
                updatedTask.Relationship_Owner__c = contactMap.get(updatedTask.WhoId);
            }
        }
    }


 
Hi Friends, 

I know null pointer errors are such a common question I hate to add another one. But I can't figure out what I am doing wrong and I am hoping I can learn something here.  I'm getting the error from my final For Loop. I thought I had checked for it with the != null in my If statement. Hoping someone can point me in the right direction.
 
public  class UniqueEmailCountHandler {
    
    public static void uniqueRelationshipOwnerEmails(List<relationship_owner__c> roList){
        //count the unique emails  that have been sent by a relationship owner
        // add all contacts associated with relationship owner to map.         
        Map<id, Contact> contactMap = new Map<Id, Contact>([SELECT Id,
                                                            New_Relationship_Owner1__c
                                                            FROM Contact
                                                            WHERE New_Relationship_owner1__c IN : roList]);
        system.debug('Number of relationship owners in trigger = ' + roList.size());
        system.debug('Contacts found = ' + contactMap.size());
        //put tasks where whoId is in the contact map into a new map
        List<Task> taskList = [SELECT Id, WhoId,Subject
                               FROM Task 
                               WHERE WhoId IN :contactMap.keySet()
                               AND Subject LIKE '%Pardot List %'];
        system.debug('Tasks Found  and added to map = ' + taskList.size());
        
        //use set to dedupe the list
        Map<Id, Set<String>> subjectLineMap = new Map<Id, Set<String>>();
        
        for(task t : taskList){
            Id ownerId = contactMap.get(t.WhoId).New_Relationship_Owner1__c;            
            if(!subjectLineMap.containsKey(ownerId)){
                subjectLineMap.put(ownerId, new Set<String>());
                system.debug('Subect Line found ' + t.Subject);              
                
            }
            Set<String> subjects = subjectLineMap.get(OwnerId);
            subjects.add(t.Subject);
            subjectLineMap.put(OwnerId, Subjects);
            
        }
        system.debug('Map size   =' + subjectLineMap.size());
        system.debug('map values =' + subjectLineMap.values());
        system.debug('map keys   =' + subjectLineMap.Keyset());
        {
            for(relationship_owner__c relationshipOwner : roList){
                if(subjectLIneMap.get(relationshipOwner.Id).size() != Null){
                relationshipOwner.Unique_Emails_Sent__c = subjectLIneMap.get(relationshipOwner.Id).size();
                }
                
            }

 
Hello Friends. 

I am hoping someone can help me with this method. I have been working on it all afternoon with no luck.  My requirement is to get to a  count of tasks that are related to contacts and place a value on a custom object. The custom object relationship_owner__C is the parent in a  look up a relationship with the Contact object. 

When a relationship_owner__C is updated then look for all contacts owned by the relationship owner with tasks that begin with the phrase "Pardot List" Evaluate the text that comes after Pardot list to determine how many unique subject lines there are. 

If the relationship owner  Test Owner has 5 contacts and Each Contact has Two Tasks with the Subject Line Pardot List 1 and Pardot List 2. The relationship owner would be updated with a  total unique value of 2.  When I test in the UI I get a value of 1 no matter how many tasks I create. And my test class for a single email fails its assertions and says 0 emails.

Here is my method.  It is called from a trigger handler on before update. 
public static void uniqueRelationshipOwnerEmails(List<relationship_owner__c> roList){
        //count the unique emails  that have been sent by a relationship owner
        // add all contacts associated with relationship owner to map.         
        Map<id, Contact> contactMap = new Map<Id, Contact>([SELECT Id,
                                                            New_Relationship_Owner1__c
                                                            FROM Contact
                                                            WHERE New_Relationship_owner1__c IN : roList]);
        system.debug('Number of relationship owners in trigger = ' + roList.size());
        system.debug('Contacts found = ' + contactMap.size());
        //put tasks where whoId is in the contact map into a new map
        List<Task> taskList = [SELECT Id, WhoId,Subject
                               FROM Task 
                               WHERE WhoId IN :contactMap.keySet()
                               AND Subject LIKE '%Pardot List %'];
        system.debug('Tasks Found  and added to map = ' + taskList.size());
        
        //use set to dedupe the list
        Map<Id, Set<String>> subjectLineMap = new Map<Id, Set<String>>();
        
        for(task t : taskList){
            Id ownerId = contactMap.get(t.WhoId).New_Relationship_Owner1__c;            
            if(!subjectLineMap.containsKey(ownerId)){
                subjectLineMap.put(ownerId, new Set<String>());
                system.debug('Subect Line found ' + t.Subject);
               
                
            }

 
trigger CountUniqueEmails on relationship_owner__c (before insert, before update) {
    for (Relationship_Owner__c   rOwner : trigger.new){
        
        //get list of on tasks belonging to owner that contain "Pardot"    
    LIST<Task> taskList = [SELECT ID,
                           Subject
                           FROM Task
                           WHERE Subject LIKE 'Pardot'
                          AND WhoId = :rOwner.Id];
        system.debug(taskList.size() + 'Matching tasks found');
        
        //if matches are found        
        if(!tasklist.isEmpty()){
            String pardotSubject = 'none';
            Integer uniqueCount = 0;
            //loop through matches and increment count if unqique
            for( Task t : taskList){
                if( pardotSubject != t.Subject){
                    uniqueCount = uniqueCount +1; 
                    system.debug('Unique count' + uniqueCount);
                }
                rOwner.Unique_Emails_Sent__c = uniqueCount;
                insert rOwner;               
                
            }            
            
        }
    } 
    
    
    //need a list of all tasks that contain pardot that belong to the relationship owner
    //Loop through tasks  to a get a count of unique subjects
    //Update Relationship Owner. 

}
trigger CountUniqueEmails on relationship_owner__c (before insert, before update) {
    for (Relationship_Owner__c   rOwner : trigger.new){
        
        //get list of on tasks belonging to owner that contain "Pardot"    
    LIST<Task> taskList = [SELECT ID,
                           Subject
                           FROM Task
                           WHERE Subject LIKE 'Pardot'
                          AND WhoId = :rOwner.Id];
        system.debug(taskList.size() + 'Matching tasks found');
        
        //if matches are found        
        if(!tasklist.isEmpty()){
            String pardotSubject = 'none';
            Integer uniqueCount = 0;
            //loop through matches and increment count if unqique
            for( Task t : taskList){
                if( pardotSubject != t.Subject){
                    uniqueCount = uniqueCount +1; 
                    system.debug('Unique count' + uniqueCount);
                }
                rOwner.Unique_Emails_Sent__c = uniqueCount;
                insert rOwner;               
                
            }            
            
        }
    } 
    
    
    //need a list of all tasks that contain pardot that belong to the relationship owner
    //Loop through tasks  to a get a count of unique subjects
    //Update Relationship Owner. 

}

 
I  am trying to update some custom meta records. There are current 4384 records in the system. And updating  gives me an error of "Collection size 4,384 exceeds maximum size of 1,000." This happens even if I try to upload fewer than 1000 records.
I tried to delete them from the Workbench and just start over. But I get an error that I have insufficient access rights on object Id.
I am trying to comment out a couple old triggers that my Org does not use anymore. They are commented out in the Sandbox and set to inactive. I have also commented out the test classes and the trigger handlers in the sandbox. 

But I am not able to deploy because one the triggers and two of the test classes are on an object that no longer exists. I am getting a  failure because my code coverage is only 63%  The tests that are failing are the ones that I want to turn off along with their trigger. How can I deal with this?
Hi I am trying to work through the Custom Controller challenge in Trailhead.  My VF page is giving me the error : 
Visualforce Error
Help for this Page
System.QueryException: unexpected token: ORDER 
Class.ContactsListController.getContacts: line 7, column 1

I am not seeing anything wrong with my code.  Any thoughts on where I am going wrong?
apex:page controller="ContactsListController">
    <apex:form >
        <apex:pageBlock title="Contacts List" id="contacts_list">
            <apex:pageBlockTable value="{! contacts}" var="ct">
                <apex:column value="{!ct.FirstName}"/>
                <apex:column value="{! ct.LastName}"/>
                <apex:column value="{! ct.Title}"/>
                <apex:column value="{! ct.Email}"/>                                                  
            
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>   
    
</apex:page>


public class ContactsListController {
    
    private String sortOrder = 'LastName';
    
    public List<Contact> getContacts(){
    
    	LIST<Contact> results = Database.query(
            'SELECT Id, FirstName, LastName, Title, Email' +
            'FROM Contact ' + 
            'ORDER BY ' + sortOrder + ' ASC ' + 
            'LIMIT 10'
        );
        return results;
    
            }
}

 
I need to build a button that links to visual force page so my users can export directly to Excel.  But I am getting errors trying to connect to the related lists. I related list is called "influencers" It is a list on a custom object called Lists. The related list are contacts that are connected via a junction object calls Relationship Owner.  Lists__c , Relationship_Owner__C and Contacts.  On Schema Builder the name of the relationship from Lists to Releionship_Owner is "lists"

If I try to access via <apex:relatedlist/> I get an error that "Contacts is not a valid child relationship name for entity list.  I get the same error if I try to use <apex:relatedlist list ="lists__r>

I have also tried to build a table that connected all three via dot notation and still can get the related list to appear.  Pretty new to Visualforce and Salesforce Development. Any help would be great. 
<apex:page standardController="Lists__c">
    <apex:pageBlock title="Influencers">    
    	<apex:pageBlockTable value="{!Lists.Lists__r.contacts}" var="contacts">        
   	    </apex:pageBlockTable>        
   </apex:pageBlock>
</apex:page>