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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 21
    Replies
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>

 
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>

 
Hello,
I tried many times... but receive the same error message : "Challenge Not yet complete... here's what's wrong: 
Formula in custom field 'Account Annual Revenue' is not correct. Check the instructions."
I followed all instructions & get the right results. It's a basic & very simple formula.
Do someone else encounter the same issue ? Any solution ?