• HNT_Neo
  • SMARTIE
  • 705 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 5
    Likes Received
  • 29
    Likes Given
  • 122
    Questions
  • 188
    Replies

When users are saving records the below error message appears.


What causes this to error out, since it doesn't seem to happen each time?


How can I go about correcting the Apex syntax with what I've provided?

Thanks in advance!

Error message: 
 

triggerUpdAssignedLead: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 101

Class.LeadTrigger.AssignLeads: line 706, column 1
Class.LeadTrigger.LeadUpdate: line 231, column 1
Trigger.triggerLead: line 7, column 1
Line 706, column 1
//Retrieve number of Assigned Leads to create
//Add for loop to avoid error if value not set in custom object, defaults to 0
        Double Number2Assign = 0;
        CustomParameters__c cp = [Select BG_Assigned_Leads__c, PR_Assigned_Leads__c From CustomParameters__c where name = 'Default'];
Line 231
starting from line 230


System.Debug('leadsforAssignment: ' +  leadsforAssignment);
        AssignLeads(leadsforAssignment);
Entire Trigger.triggerLead Apex syntax listed, line 7 starts with: 
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
      lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
      lt.AddToCampaign(Trigger.New, Trigger.oldMap);
      lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
      lt.PopulateAmbassador(Trigger.New, Trigger.old);   
      
    
    // 10/22/2015 Ambassador enhancement Tia Xuan 
    if (Trigger.isBefore && Trigger.isUpdate){
      lt.CreateLastVisitTask(Trigger.new);
      lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}



 
I'm running into an issue with our LeadTrigger Apex Class. The error message received via email was: 

Apex script unhandled trigger exception by user/organization: 005A0000008YrGG/00DA0000000ISJM

triggerUpdAssignedLead: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 101

Class.LeadTrigger.PopulateAmbassador: line 438, column 1
Trigger.triggerLead: line 14, column 1


Starting at line 438 is the apex code causing the error below. 
Can someone help in finding a solution? I believe this may be caused by a FOR loop issue? 

I've also included the Apex Trigger code below this code, since it was referenced in the error message. 
 
List<Ambassador__c> ambs = [select id, Ambassador_ID__c, Ambassador_Name__c from Ambassador__c where Ambassador_ID__c =: ambassadorIds];
        
        Map<String, Ambassador__c> ambMap = new Map<String, Ambassador__c>();
        
        for (Ambassador__c amb : ambs)
            ambMap.put(amb.Ambassador_ID__c, amb);
        
        for (Lead ld : leadsToTreat) {
            if (ambMap.containsKey(ld.Ambassador_ID__c)) {
                ld.Ambassador_Name__c = ambMap.get(ld.Ambassador_ID__c).Ambassador_Name__c;
            }
        }   
    }

This is the Trigger.triggerLead Apex code which was referenced in the error message. Line 14 starts as: 

lt.PopulateAmbassador(Trigger.New,
 
Trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
      lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
      lt.AddToCampaign(Trigger.New, Trigger.oldMap);
      lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
      lt.PopulateAmbassador(Trigger.New, Trigger.old);   
      
    if (Trigger.isBefore && Trigger.isUpdate){
      lt.CreateLastVisitTask(Trigger.new);
      lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}

 
Hello, 

We have a class and trigger in place which is now producing the error listed below. It is referencing an Apex Class and an Apex Trigger of where the issue is stemming from. 

Can someone help me figure out how I can correct this? 

Thank you!
 
Apex script unhandled trigger exception by user/organization: 005A0000005XYZb/00DA0000033432M

triggerUpdAssignedLead: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 101

Class.LeadTrigger.<init>: line 47, column 1
Trigger.triggerLead: line 3, column 1

Line 47  of the Class.LeadTrigger can be found in this class code below:  
for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
 
public without sharing class LeadTrigger {
    //private static boolean alreadyExecuted = false;
    Private Set<String> OpenLeadStatus = new Set<String>{'Awaiting Decision','Initiating Contact','New', 'Quoting', 'Re-Engaged', 'Job Take'};
    Private String QuotingStatus = 'Quoting';
    Private String QuotingCampaignNumber = '34099';
    Private static String MODELER_LEAD = 'Modeler Lead';
    Private static String HOW_LEAD = 'Show Lead';
    Private static String STATUE = 'Statue';
    public static String ClosedStatus = 'Closed By EF';
    public static String ProjectDelayedStatus = 'Project Ending';
    //public static boolean isTest {get; set;}
    //public static boolean isTestUpdateLead {get; set;}
    public static boolean isUpdateLeadStatus {get; set;}
    public static boolean isUpdateHistoryLog {get; set;}
    
    //New class variable creatd for optimization - 10/2016
    //Prevent SOQL Query governor limit exception
    private Map<String,Id> recTypes = new Map<String,Id>();
    private final string queueInsideSalesId;
    private final string dummyCampaignId = null;
    private Map<Id, User> activeUsers = new Map<Id, User>();
    private Set<Id> excludedZipAssignUsers = new Set<Id>();
    
    //Creating class constructor to initialize class objects - 11/2017
    //Prevent SOQL Query governor limit exception
    public LeadTrigger(){
        //Retrieving RecordType information
        for(Schema.RecordTypeInfo rt : Lead.SObjectType.getDescribe().getRecordTypeInfos()){
            String rtName = rt.getName();
            if((rtName == MODELER_LEAD)||(rtName == SHOW_LEAD)){ 
                recTypes.put(rtName, rt.getRecordTypeId());
            }
        }
        
        //Retrieving values for the Lead Assignment - AssignLeads() method
        //Retrieving the default owner (Inside Sales Queue)
        for(QueueSobject queue : [Select QueueId From QueueSobject Where SobjectType = 'Assigned_Lead__c' and Queue.Name = 'Inside Sales']){
            queueInsideSalesId = queue.QueueId;
        }
        
        //Retrieving Dummy Campaign ID for Assigning New Leads to a Campaign
        for(Campaign c : [Select Id, Campaign_Number__c From Campaign Where Name Like '%Dummy%' Limit 1]){
            dummyCampaignId = c.Id;
        }
        
        // Retrieving Active Users List for Lead Assignment
        for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
            //Retrieving Users excluded by Zip Assignment
            if(u.Exclude_from_Zip_Placement__c ==  true){
                excludedZipPlaceUsers.add(u.Id);
            }else{
                activeUsers.put(u.Id, u);
            }
        }
    }


This is the ApexTrigger code named referenced in the apex error code: 
Trigger.triggerLead: line 3, column 1
 
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
      lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
      lt.AddToCampaign(Trigger.New, Trigger.oldMap);
      lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
      lt.PopulateAmbassador(Trigger.New, Trigger.old);   
      
    
    // 10/22/2015 Ambassador enhancement Tia Xuan 
    if (Trigger.isBefore && Trigger.isUpdate){
      lt.CreateLastVisitTask(Trigger.new);
      lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}





 
Hello, 
Trying to cancel an apex batch job but no luck making it work. 

This is the apex code I'm using and the error results are below. Any help is greatly appreciated!
 
string SCHEDULE_NAME = 'MergeMetricsCalculationBatchable';
System.abortJob(SCHEDULE_NAME);
 
Execute anonumous error

Line: 2, Column: 1
System.StringException: Only CronTrigger IDs and batch, future, and queueable job IDs are supported.

 
Hello, 

We have a Lead Trigger set in our org and its been active since 2013. 
 I came across this Salesforce document stating that the first name and last name character limits have increased. 

https://help.salesforce.com/articleView?id=leads_fields.htm&type=5

First Name character limit is 40
Last Name character limit is 80

So created a lead with 30 characters for the first name and 40 for the last name, to be modest. Well, I received the error message that the max limit is 20 characters, etc. Contacted Salesforce, and concluded that a custom lead trigger, shown below, was the culprit. I deactivated it, tested a new lead with the number of characters I tried before, and it worked. 

Unfortunately, I can't deactivate this trigger in production since it is executing various actions. Is there a way to modify this code to allow the first and last name to increase the character limits when a new lead is created? 

The past few months we've been receiving email erroring out and we found out why, but now need to know if anyone can help me out. 

Thanks!
 
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
        lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
        lt.AddToCampaign(Trigger.New, Trigger.oldMap);
        lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
        lt.PopulateAmbassador(Trigger.New, Trigger.old);   
        
    if (Trigger.isBefore && Trigger.isUpdate){
        lt.CreateLastVisitTask(Trigger.new);
        lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}

 
This has reared its ugly head once again. 
Ran this in Sandbox and was fine until it ran in Production. 

System.NullPointerException: Attempt to de-reference a null object

Class.VolumeMarketBatch.execute: line 39, column 1
 
global with sharing class VolumeMarketBatch implements Database.batchable<sObject> {  // updated implements 1-13-2019 nfs
    
    
    global Database.QueryLocator start(Database.BatchableContext info) {
        
        // Go through and get the list of volume market that has changed
        String returnQuery = 'select Id, Remodeler_Account__c, Postal_Code__c ' +
            '   from Zip_Assignment__c ' +  
            '   where Postal_Code__r.Volume_Market_Update__c = true';
        
        return Database.getQueryLocator(returnQuery); 
        
    }
    
    global void execute(Database.BatchableContext info, List<sObject> sobjectList) {
        // Gets the account and postal codes that have changed
        List<Id> accountIdList = new List<Id>();
        List<Id> pcIdList = new List<Id>();
        for (sObject obj : sobjectList) {
            Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
            if (zipAssign.Remodeler_Account__c != null && zipAssign.Postal_Code__c != null){ // added 1-13-2019 nfs
                accountIdList.add(zipAssign.Remodeler_Account__c);
                pcIdList.add(zipAssign.Postal_Code__c);
            }          
        }
        
        
        // Goes through the accounts and postal codes that have changed and sets the Volume Market field on the account
        Map<Id, Account> accountList = new Map<Id, Account>([select Id, Volume_Market__c from Account where Id = : accountIdList]); 
        Map<Id, Postal_Code__c> pcList = new Map<Id, Postal_Code__c>([select Id, Volume_Market_Update__c, Volume_Market__c from Postal_Code__c where Id = : pcIdList]);
        
        for (sObject obj : sobjectList) {
            Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
            Account a = accountList.get(zipAssign.Remodeler_Account__c);
            Postal_Code__c pc = pcList.get(zipAssign.Postal_Code__c);
            //System.Debug(pc.Volume_Market__c + a.Volume_Market__c);
            if (pc != null) { 
                if (pc.Volume_Market__c != null) {
                    a.Volume_Market__c = pc.Volume_Market__c;
                }
                pc.Volume_Market_Update__c = false;
            }
        }
        
        // updates both account and postal codes
        upsert accountList.values();
        upsert pcList.values();
    }
    
    global void finish(Database.BatchableContext info) {
        
        
    }
    
}

 
Hi Everyone, 

I need help in making sense of this Apex class that was created years ago in our org. 

Today we ran into an Apex script unhandled exception 

Failed to process batch for class 'VolumeMarketBatch' 

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.VolumeMarketBatch.execute: line 36, column 1

line 36 below is: 
a.Volume_Market__c = pc.Volume_Market__c;​​​​​​​

Any help is greatly appreciated. 

Thank you

 
global with sharing class VolumeMarketBatch implements Database.batchable<sObject> {

	
	global Database.QueryLocator start(Database.BatchableContext info) {

		// Go through and get the list of volume market that has changed
		String returnQuery = 'select Id, Remodeler_Account__c, Postal_Code__c ' +
							 '	from Zip_Assignment__c ' +  
							 '	where Postal_Code__r.Volume_Market_Update__c = true';

        return Database.getQueryLocator(returnQuery); 
   
	}
	
	global void execute(Database.BatchableContext info, List<sObject> sobjectList) {
		// Gets the account and postal codes that have changed
		List<Id> accountIdList = new List<Id>();
		List<Id> pcIdList = new List<Id>();
		for (sObject obj : sobjectList) {
			Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
			accountIdList.add(zipAssign.Remodeler_Account__c);
			pcIdList.add(zipAssign.Postal_Code__c);
		}
		
		// Goes through the accounts and postal codes that have changed and sets the Volume Market field on the account
		Map<Id, Account> accountList = new Map<Id, Account>([select Id, Volume_Market__c from Account where Id = : accountIdList]);
		Map<Id, Postal_Code__c> pcList = new Map<Id, Postal_Code__c>([select Id, Volume_Market_Update__c, Volume_Market__c from Postal_Code__c where Id = : pcIdList]);
		
		for (sObject obj : sobjectList) {
			Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
			Account a = accountList.get(zipAssign.Remodeler_Account__c);
			Postal_Code__c pc = pcList.get(zipAssign.Postal_Code__c);
			//System.Debug(pc.Volume_Market__c + a.Volume_Market__c);
			if (pc != null) { 
				if (pc.Volume_Market__c != null) {
					a.Volume_Market__c = pc.Volume_Market__c;
				}
				pc.Volume_Market_Update__c = false;
			}
		}
		
		// updates both account and postal codes
		upsert accountList.values();
		upsert pcList.values();
	}
	
	global void finish(Database.BatchableContext info) {
		
	
	}

}

 
I’m trying to delete a scheduled apex batch job using the syntax below. However, the syntax will delete all scheduled apex jobs, is it possible to delete just 1 scheduled job and if possible, what would the syntax look like?
 
SELECT CreatedDate,CronExpression,CronJobDetailId,Id,NextFireTime,OwnerId.Name,PreviousFireTime,StartTime,State,TimesTriggered FROM CronTrigger

 
Hello everyone, need some help with a trigger I created. 

As you can see, my code doesn't have an alternative to a bank selection. 

For example, if a user leaves the picklist value blank and saves the record, an Apex error code will fire off, and post the error code at the top of the page. 

Is thseir a way to have this trigger skip this record if a blank value exists? That way a user can still save a record. if a blank value is needed. 

thanks!
 
trigger CAPdataTiers on CAPdata__c (before insert, before update) {
    for (CAPdata__c CAP : Trigger.new) {s
        if(CAP.Volume_Market__c.equalsIgnoreCase('As') && 
           CAP.Region_Program_Requirements__c != null && 
           CAP.Region_Program_Requirements__c.equalsIgnoreCase('Midwest'))
        {    
            CAP.TierElitePreferredJobs__c = 36; 
            CAP.TierElitePreferredRV__c = 90000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 24; 
            CAP.TierPreferredRV__c = 60000;
            CAP.TierPreferredL6MosTA__c = 75;
            CAP.TierRewardsAdvantageJobs__c = 12;
            CAP.TierRewardsAdvantageRV__c = 30000;
            CAP.TierRewardsAdvantageL6MosTA__c = 75;
        }
        else if(CAP.Volume_Market__c.equalsIgnoreCase('B') &&
           CAP.Region_Program_Requirements__c != null && 
           CAP.Region_Program_Res/Midwest Market B
            CA sP.TierElitePreferredJobs__c = 18; 
            CAP.TierElitePreferredRV__c = 45000;
            CAP.TierElitePreferredL6MosTA__c = 90;
            CAP.TierElitePreferredL6MosDA__c = 90;
            CAP.TierPreferredJobs__c = 12; 
            CAP.TierPreferredRV__c = 30000;
            CAP.TierPreferredL6MosTA__c = 50;
            CAP.TierRewardsAdvantageJobs__c = 6;
            CAP.TierRewardsAdvantageRV__c = 15000;
            CAP.TierRewardsAdvantageL6MosTA__c = 25;
        }
}

 
Hello, 
Need some help with creating an Apex Test Class for this Apex Class I created which populates a custom object's country field's as either Canada or United States. I attempted to start creating the Apex Test Class but ended up not being able to create it. 
 
global class PostalCodeUtils {
  public static String getPCCountry(String postalCode){
    if (postalCode == null ||  postalCode.length() <= 1){
      return 'United States';
    }
    if (!postalCode.trim().left(1).isNumeric()) {
      return 'Canada';
    } else {
      return 'United States';
    }
  }
  
  public static String getPCID(String postalCode, String pcCountry){ 
    if (postalCode == null){
      return '';
    }
    
    if (pcCountry == 'Canada'){
      if (postalCode.length() >= 3){
        return postalCode.substring(0, 3).toUpperCase();
      }  
    } else {
      if (postalCode.length() >= 5){
        return postalCode.substring(0, 5);
      }
      
    }
    return postalCode; 
    
  }
}

This is my attempt in creating the Apex Test Class (generic Salesforce template): 
@isTest
private class PostalCodeUtilss {
	
	@isTest static void test_method_one() {
		// Implement test code
	}
	
	@isTest static void test_method_two() {
		// Implement test code
	}
	
}
Any ideas? Please let me know. 

 
Hello, 

I have this formula number field in the custom activities object which counts a value of 1 if an event or task record is created from the opportunity record. 
IF(NOT(ISBLANK(Opportunity__c)), 1, 0)
I want to be able to use the same concept to build a formula that will only target a certain opportunity record type. 

The Opportunity Record Type Name = XYZ

I'd like to know when an event or task is created against an opportunity record type of XYZ. 

I've attached a screenshot of the current formula we are using, in order for anyone to get an idea what I'm trying to achieve. 

User-added image

Thanks
 
  • September 27, 2018
  • Like
  • 0
Looking to creating a validation rule on the user object that when IsActive is unchecked, a custom date field (Deactivated_Date__c) must have a value if the save button clicked. If the custom date field is blank, user should receive an error to fill in the date if NULL. 

Is this possible? 
AND ( 
ISBLANK (Deactivated_Date__c),
(IsActive != NULL)
)

 
  • September 08, 2018
  • Like
  • 0
I've followed the documentation from the Lightning Components Developer Guide on Dynamically Showing or Hiding Markup using a component, js controller and style elements. I was able to place the button on my lightning home page, however, when I click the button, the sample text does not disappear as shown. 

Has anyone run into this problem or is there something missing that wouldn't toggle the sample text provided?

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_show_hide_markup.htm

Component
<!--c:toggleCss-->
<aura:component>
    <lightning:button label="Toggle" onclick="{!c.toggle}"/>
    <p aura:id="text">Now you see me</p>
</aura:component>

js controller
/*toggleCssController.js*/
({
    toggle : function(component, event, helper) {
        var toggleText = component.find("text");
        $A.util.toggleClass(toggleText, "toggle");
    }
})

style
/*toggleCss.css*/
.THIS .toggle {
    display: none;
}

 
  • September 06, 2018
  • Like
  • 0
Hello, 

I've managed to create a custom page for salesforce mobile through the lightning app builder. However,when naming the app page, for example My Salesforce, is there a way to hide this header part using the display:none syntax? If so, where could I hide this header using css? 

User-added image
Hello,
I may have gone in the wrong direction on this but what I'm trying to do is when a user clicks a custom lightning component button (My Opportunities) it directs them to the Recent Opportunities page within Salesforce mobile. I've created a simple prototype in the URL below.

I created the component, but I'm not sure what the button syntax should look like. I want to use the lightning:icon I'm using as the button.

I had created a controller to an Apex class, but I doubt I need that if I just need a button of some sort to redirect the user to the Recent Opportunities. 

Please let me know what I need or need to modify. 

Thanks! 

 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="MyOpportunityListController" access="global" >
    
    <aura:handler name="init" action="{!c.myAction}" value="{!this}" />
    <aura:attribute name="opportunity" type="Opportunity[]" />
    <ul>
        <aura:iteration items="{!v.opportunity}" var="opportunity">
            <li class="minli"> <h3>{!opportunity.Name}</h3> </li>
        </aura:iteration>
    </ul> 
    
<div class="slds-p-around_medium" style="text-align:center">
    <lightning:icon iconName="standard:opportunity" size="large" alternativeText="My Opportunities"/>
    <h3>Opportunities</h3>
</div>
</aura:component>



https://projects.invisionapp.com/share/5PNMNDF2U4N#/screens/314503251
I want the ability to create a 9 box type box like the below using the Lightning Builder, is this possible? 

Component
<aura:component implements="lightning:homeTemplate" access="global" >
    <aura:attribute name="center" type="Aura.Component[]" />
    <aura:attribute name="left" type="Aura.Component[]" />
    <aura:attribute name="right" type="Aura.Component[]" />
    
    <div class="slds-grid slds-wrap">
        <div class="slds-col slds-size_1-of-3">
            <span>{!v.left}</span>
        </div>
        <div class="slds-col slds-size_1-of-3">
            <span>{!v.center}</span>
        </div>
        <div class="slds-col slds-size_1-of-3">
            <span>{!v.right}</span>
        </div>        
    </div>
</aura:component>

Design
<design:component label="Three column Page">
    <flexipage:template>
        
        <flexipage:region name="left" defaultWidth="SMALL">
            <flexipage:formfactor type="MEDIUM" width="SMALL"/>
        </flexipage:region>
        
        <flexipage:region name="center" defaultWidth="SMALL">
            <flexipage:formfactor type="MEDIUM" width="SMALL"/>
        </flexipage:region>
               
        <flexipage:region name="right" defaultWidth="SMALL">
            <flexipage:formfactor type="MEDIUM" width="SMALL"/>
        </flexipage:region>
        
    </flexipage:template>
</design:component>


User-added image
I've managed to create a lightning homepage component with 1 column using the below component, style, and design elements. If I re-use the {!v.main} in the component page more than once, I receive an error. 

I want to be able to create 3 horizontal sections as shown in the last image below. Is it possible? 

COMPONENT
<aura:component implements="lightning:homeTemplate">
    <aura:attribute name="main" type="Aura.Component[]" /> 
    <div>
        <lightning:layout horizontalAlign="spread">
            {!v.main}
        </lightning:layout>
    </div>
</aura:component>

DESIGN
<flexipage:template >
        <flexipage:region name="main" defaultWidth="Xlarge">
        </flexipage:region>
    </flexipage:template>

SVG
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="120px" height="120px" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
		<path d="M120,108 C120,114.6 114.6,120 108,120 L12,120 C5.4,120 0,114.6 0,108 L0,12 C0,5.4 5.4,0 12,0 L108,0 C114.6,0 120,5.4 120,12 L120,108 L120,108 Z" id="Shape" fill="#2A739E"/>
		<path d="M77.7383308,20 L61.1640113,20 L44.7300055,63.2000173 L56.0543288,63.2000173 L40,99.623291 L72.7458388,54.5871812 L60.907727,54.5871812 L77.7383308,20 Z" id="Path-1" fill="#FFFFFF"/>
	</g>
</svg>

This is the error I receive
User-added image

This is the layout I can render but doesn't work if I add components to it
User-added image

Hello outhere!

Looking for some help with this js controller that is giving me the following error (attached a full image of the component error too):

Uncaught Error in $A.getCalleback() [Cannot read property 'style' of null]
It's referencing the JS controller as the culprit: floatingMarqueeHelper.js

The scrolling marquee does show up but I have to clear the error message out each time which isn't good practice. 

I will include all my component code below for any insights into this. 

Thanks!

floatingMarquee.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="intervalId" type="Integer" default="0"/>
    
    <div id="parentDIV" style="overflow:hidden">
        <p style="position:relative;" id="tofloat">
            <b><span style="color:red">Important Note : </span>
                Get it Done Today</b>
        </p>
    </div>
</aura:component>



floatingMarqueeController.js
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="intervalId" type="Integer" default="0"/>
    
    <div id="parentDIV" style="overflow:hidden">
        <p style="position:relative;" id="tofloat">
            <b><span style="color:red">Important Note : </span>
                Get it Done Today</b>
        </p>
    </div>
</aura:component>


floatingMarquee.css
.THIS#parentDIV{
    font-size: 1rem;
    background: white;
    background-clip: padding-box;
    height: 50px;
    margin: 0px;
    padding: 1rem;
}


floatingMargueeHelper.js
({
    shiftDiv: function(component, event,lWidth) {
        var changeposition = component.get("v.intervalId");
        var floatElement = document.getElementById('tofloat');	  
        if(changeposition < lWidth){
            floatElement.style.left = changeposition+'px';
            changeposition = changeposition + 5;
            component.set("v.intervalId",changeposition);
        }
       
        else{
            component.set("v.intervalId",0);  //reset left to 0
            floatElement.style.left = "0px";
            changeposition = component.get("v.intervalId"); //resets to trigger the IF block, similar to a loop
        }
    }
})
 



 

Hello, 

Working on creating an aggregated Apex Class with a SOQL query, but before I can build out the class, my soql query isn't producing the column headers, but show up as, Unknown_Field__1 , Unknown_Field__2, Unknown_Field__3. 

The values produced are correct though. 

When I query this in workbench, I got the results shown below. 
SELECT
SUM(Converted_Monthly_Sqft__c),
COUNT(Name),
CALENDAR_MONTH(CloseDate) Date_Converted_Month_Year__c
FROM 
Opportunity
WHERE stageName = 'Conversion' AND CALENDAR_YEAR(CloseDate) = 2018
GROUP BY CALENDAR_MONTH(CloseDate)
ORDER BY CALENDAR_MONTH(CloseDate)
WorkbenchImage
Converted_Monthly_Sqft__c is a number field

If someone can let me know what I'm doing wrong or point me in the right direction, it will be appreciated. 


Once this is correct, the SOQL Query will be placed inside my Apex Class: 
public class RealChartController {
    public List<AggregateResult> getData() {
        return
            [SUM(Total_Converted_Volume_Sqft__c) , 
            COUNT(Name) numOppsConversion,
            CALENDAR_MONTH(CloseDate) theMonth
            FROM 
            Opportunity
            WHERE stageName = 'Conversion' AND CALENDAR_YEAR(CloseDate) = 2018
            GROUP BY CALENDAR_MONTH(CloseDate)
           ORDER BY CALENDAR_MONTH(CloseDate)];
    }
}

 
Can someone help me understand what this apex trigger is doing? Someone set this up in our org, in the event object and having a hard time understanding what its doing: 
 
trigger Events on Event (before insert, before update, after insert, after delete) 
{

  if ( trigger.isBefore)
  {
    if ( trigger.isInsert || trigger.isUpdate)
    {
      if(AccountCallRollup.batch_update_running!=true)
        {
        //Events.ActivityCallRollup(Trigger.new);
        }

      Events.PopulateActivityFields( trigger.new );
    //5/5/2018: Consolidated from separate trigger
      Events.Event_User_field_from_Assigned_To_Before(Trigger.new);
    }

    //if(trigger.isDelete && AccountCallRollup.batch_update_running!=true)
    //  {
    //  Events.ActivityCallRollup(Trigger.old);
    //  }

  }

  if ( trigger.isAfter)
  {
    if ( trigger.isInsert || trigger.isUpdate)
    {
    //5/5/2018: Consolidated from separate trigger
      Events.Event_User_field_from_Assigned_To_After(Trigger.new);
    if(AccountCallRollup.batch_update_running!=true)
      {
      //6/22/18: Turn off immediate rollup
      //Events.ActivityCallRollup(Trigger.new);
      }
    } 
  }

    if(AccountCallRollup.batch_update_running!=true && trigger.isDelete)
      {
      //6/22/18: Turn off immediate rollup
      //Events.ActivityCallRollup(Trigger.old);
      }


}

 
Hello, 

We have a class and trigger in place which is now producing the error listed below. It is referencing an Apex Class and an Apex Trigger of where the issue is stemming from. 

Can someone help me figure out how I can correct this? 

Thank you!
 
Apex script unhandled trigger exception by user/organization: 005A0000005XYZb/00DA0000033432M

triggerUpdAssignedLead: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 101

Class.LeadTrigger.<init>: line 47, column 1
Trigger.triggerLead: line 3, column 1

Line 47  of the Class.LeadTrigger can be found in this class code below:  
for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
 
public without sharing class LeadTrigger {
    //private static boolean alreadyExecuted = false;
    Private Set<String> OpenLeadStatus = new Set<String>{'Awaiting Decision','Initiating Contact','New', 'Quoting', 'Re-Engaged', 'Job Take'};
    Private String QuotingStatus = 'Quoting';
    Private String QuotingCampaignNumber = '34099';
    Private static String MODELER_LEAD = 'Modeler Lead';
    Private static String HOW_LEAD = 'Show Lead';
    Private static String STATUE = 'Statue';
    public static String ClosedStatus = 'Closed By EF';
    public static String ProjectDelayedStatus = 'Project Ending';
    //public static boolean isTest {get; set;}
    //public static boolean isTestUpdateLead {get; set;}
    public static boolean isUpdateLeadStatus {get; set;}
    public static boolean isUpdateHistoryLog {get; set;}
    
    //New class variable creatd for optimization - 10/2016
    //Prevent SOQL Query governor limit exception
    private Map<String,Id> recTypes = new Map<String,Id>();
    private final string queueInsideSalesId;
    private final string dummyCampaignId = null;
    private Map<Id, User> activeUsers = new Map<Id, User>();
    private Set<Id> excludedZipAssignUsers = new Set<Id>();
    
    //Creating class constructor to initialize class objects - 11/2017
    //Prevent SOQL Query governor limit exception
    public LeadTrigger(){
        //Retrieving RecordType information
        for(Schema.RecordTypeInfo rt : Lead.SObjectType.getDescribe().getRecordTypeInfos()){
            String rtName = rt.getName();
            if((rtName == MODELER_LEAD)||(rtName == SHOW_LEAD)){ 
                recTypes.put(rtName, rt.getRecordTypeId());
            }
        }
        
        //Retrieving values for the Lead Assignment - AssignLeads() method
        //Retrieving the default owner (Inside Sales Queue)
        for(QueueSobject queue : [Select QueueId From QueueSobject Where SobjectType = 'Assigned_Lead__c' and Queue.Name = 'Inside Sales']){
            queueInsideSalesId = queue.QueueId;
        }
        
        //Retrieving Dummy Campaign ID for Assigning New Leads to a Campaign
        for(Campaign c : [Select Id, Campaign_Number__c From Campaign Where Name Like '%Dummy%' Limit 1]){
            dummyCampaignId = c.Id;
        }
        
        // Retrieving Active Users List for Lead Assignment
        for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
            //Retrieving Users excluded by Zip Assignment
            if(u.Exclude_from_Zip_Placement__c ==  true){
                excludedZipPlaceUsers.add(u.Id);
            }else{
                activeUsers.put(u.Id, u);
            }
        }
    }


This is the ApexTrigger code named referenced in the apex error code: 
Trigger.triggerLead: line 3, column 1
 
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
      lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
      lt.AddToCampaign(Trigger.New, Trigger.oldMap);
      lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
      lt.PopulateAmbassador(Trigger.New, Trigger.old);   
      
    
    // 10/22/2015 Ambassador enhancement Tia Xuan 
    if (Trigger.isBefore && Trigger.isUpdate){
      lt.CreateLastVisitTask(Trigger.new);
      lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}





 
I've managed to create a lightning homepage component with 1 column using the below component, style, and design elements. If I re-use the {!v.main} in the component page more than once, I receive an error. 

I want to be able to create 3 horizontal sections as shown in the last image below. Is it possible? 

COMPONENT
<aura:component implements="lightning:homeTemplate">
    <aura:attribute name="main" type="Aura.Component[]" /> 
    <div>
        <lightning:layout horizontalAlign="spread">
            {!v.main}
        </lightning:layout>
    </div>
</aura:component>

DESIGN
<flexipage:template >
        <flexipage:region name="main" defaultWidth="Xlarge">
        </flexipage:region>
    </flexipage:template>

SVG
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="120px" height="120px" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
		<path d="M120,108 C120,114.6 114.6,120 108,120 L12,120 C5.4,120 0,114.6 0,108 L0,12 C0,5.4 5.4,0 12,0 L108,0 C114.6,0 120,5.4 120,12 L120,108 L120,108 Z" id="Shape" fill="#2A739E"/>
		<path d="M77.7383308,20 L61.1640113,20 L44.7300055,63.2000173 L56.0543288,63.2000173 L40,99.623291 L72.7458388,54.5871812 L60.907727,54.5871812 L77.7383308,20 Z" id="Path-1" fill="#FFFFFF"/>
	</g>
</svg>

This is the error I receive
User-added image

This is the layout I can render but doesn't work if I add components to it
User-added image
I have a checkbox, donotsend__c, that if checked and saved, the user will be prompted with an error in not having sufficient access to do so. 

The checkbox must not be able to be saved to true. 

Can someone help me with this validation rule? 

Thanks!
I have 4 fields ranging in percentage and currency types (as shown below) that all will be required to contain a value prior to being saved. 

Can someone assist in creating the VR for this one? Thanks!

User-added image

I want to have the ability to map a custom field, i.e., Job Name, from the lead object, to map to the Account Name window (see screenshot)

Can anyone tell me how to accomplish this?

User-added image

When users are saving records the below error message appears.


What causes this to error out, since it doesn't seem to happen each time?


How can I go about correcting the Apex syntax with what I've provided?

Thanks in advance!

Error message: 
 

triggerUpdAssignedLead: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 101

Class.LeadTrigger.AssignLeads: line 706, column 1
Class.LeadTrigger.LeadUpdate: line 231, column 1
Trigger.triggerLead: line 7, column 1
Line 706, column 1
//Retrieve number of Assigned Leads to create
//Add for loop to avoid error if value not set in custom object, defaults to 0
        Double Number2Assign = 0;
        CustomParameters__c cp = [Select BG_Assigned_Leads__c, PR_Assigned_Leads__c From CustomParameters__c where name = 'Default'];
Line 231
starting from line 230


System.Debug('leadsforAssignment: ' +  leadsforAssignment);
        AssignLeads(leadsforAssignment);
Entire Trigger.triggerLead Apex syntax listed, line 7 starts with: 
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
      lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
      lt.AddToCampaign(Trigger.New, Trigger.oldMap);
      lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
      lt.PopulateAmbassador(Trigger.New, Trigger.old);   
      
    
    // 10/22/2015 Ambassador enhancement Tia Xuan 
    if (Trigger.isBefore && Trigger.isUpdate){
      lt.CreateLastVisitTask(Trigger.new);
      lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}



 
Hello, 

We have a class and trigger in place which is now producing the error listed below. It is referencing an Apex Class and an Apex Trigger of where the issue is stemming from. 

Can someone help me figure out how I can correct this? 

Thank you!
 
Apex script unhandled trigger exception by user/organization: 005A0000005XYZb/00DA0000033432M

triggerUpdAssignedLead: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 101

Class.LeadTrigger.<init>: line 47, column 1
Trigger.triggerLead: line 3, column 1

Line 47  of the Class.LeadTrigger can be found in this class code below:  
for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
 
public without sharing class LeadTrigger {
    //private static boolean alreadyExecuted = false;
    Private Set<String> OpenLeadStatus = new Set<String>{'Awaiting Decision','Initiating Contact','New', 'Quoting', 'Re-Engaged', 'Job Take'};
    Private String QuotingStatus = 'Quoting';
    Private String QuotingCampaignNumber = '34099';
    Private static String MODELER_LEAD = 'Modeler Lead';
    Private static String HOW_LEAD = 'Show Lead';
    Private static String STATUE = 'Statue';
    public static String ClosedStatus = 'Closed By EF';
    public static String ProjectDelayedStatus = 'Project Ending';
    //public static boolean isTest {get; set;}
    //public static boolean isTestUpdateLead {get; set;}
    public static boolean isUpdateLeadStatus {get; set;}
    public static boolean isUpdateHistoryLog {get; set;}
    
    //New class variable creatd for optimization - 10/2016
    //Prevent SOQL Query governor limit exception
    private Map<String,Id> recTypes = new Map<String,Id>();
    private final string queueInsideSalesId;
    private final string dummyCampaignId = null;
    private Map<Id, User> activeUsers = new Map<Id, User>();
    private Set<Id> excludedZipAssignUsers = new Set<Id>();
    
    //Creating class constructor to initialize class objects - 11/2017
    //Prevent SOQL Query governor limit exception
    public LeadTrigger(){
        //Retrieving RecordType information
        for(Schema.RecordTypeInfo rt : Lead.SObjectType.getDescribe().getRecordTypeInfos()){
            String rtName = rt.getName();
            if((rtName == MODELER_LEAD)||(rtName == SHOW_LEAD)){ 
                recTypes.put(rtName, rt.getRecordTypeId());
            }
        }
        
        //Retrieving values for the Lead Assignment - AssignLeads() method
        //Retrieving the default owner (Inside Sales Queue)
        for(QueueSobject queue : [Select QueueId From QueueSobject Where SobjectType = 'Assigned_Lead__c' and Queue.Name = 'Inside Sales']){
            queueInsideSalesId = queue.QueueId;
        }
        
        //Retrieving Dummy Campaign ID for Assigning New Leads to a Campaign
        for(Campaign c : [Select Id, Campaign_Number__c From Campaign Where Name Like '%Dummy%' Limit 1]){
            dummyCampaignId = c.Id;
        }
        
        // Retrieving Active Users List for Lead Assignment
        for(User u : [Select Id, UserType, Contact.AccountId, Contact.Account.Member__c, Exclude_from_Zip_Placement__c From User Where isActive = true]){
            //Retrieving Users excluded by Zip Assignment
            if(u.Exclude_from_Zip_Placement__c ==  true){
                excludedZipPlaceUsers.add(u.Id);
            }else{
                activeUsers.put(u.Id, u);
            }
        }
    }


This is the ApexTrigger code named referenced in the apex error code: 
Trigger.triggerLead: line 3, column 1
 
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
      lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
      lt.AddToCampaign(Trigger.New, Trigger.oldMap);
      lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
      lt.PopulateAmbassador(Trigger.New, Trigger.old);   
      
    
    // 10/22/2015 Ambassador enhancement Tia Xuan 
    if (Trigger.isBefore && Trigger.isUpdate){
      lt.CreateLastVisitTask(Trigger.new);
      lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}





 
Hello, 
Trying to cancel an apex batch job but no luck making it work. 

This is the apex code I'm using and the error results are below. Any help is greatly appreciated!
 
string SCHEDULE_NAME = 'MergeMetricsCalculationBatchable';
System.abortJob(SCHEDULE_NAME);
 
Execute anonumous error

Line: 2, Column: 1
System.StringException: Only CronTrigger IDs and batch, future, and queueable job IDs are supported.

 
Hello, 

We have a Lead Trigger set in our org and its been active since 2013. 
 I came across this Salesforce document stating that the first name and last name character limits have increased. 

https://help.salesforce.com/articleView?id=leads_fields.htm&type=5

First Name character limit is 40
Last Name character limit is 80

So created a lead with 30 characters for the first name and 40 for the last name, to be modest. Well, I received the error message that the max limit is 20 characters, etc. Contacted Salesforce, and concluded that a custom lead trigger, shown below, was the culprit. I deactivated it, tested a new lead with the number of characters I tried before, and it worked. 

Unfortunately, I can't deactivate this trigger in production since it is executing various actions. Is there a way to modify this code to allow the first and last name to increase the character limits when a new lead is created? 

The past few months we've been receiving email erroring out and we found out why, but now need to know if anyone can help me out. 

Thanks!
 
trigger triggerLead on Lead (after insert, before insert, before update, after update) {

    LeadTrigger lt = new LeadTrigger();
    if (Trigger.isInsert)
        lt.LeadInsertion(Trigger.New, Trigger.isBefore, Trigger.isAfter);
    else if (Trigger.isBefore)
        lt.LeadUpdate(Trigger.New, Trigger.old, Trigger.isBefore);
    
    if (Trigger.isAfter) {
        lt.ReassignALOnClosedLeads(Trigger.New, Trigger.old, null);
        lt.AddToCampaign(Trigger.New, Trigger.oldMap);
        lt.ProcessQuotingLeads(Trigger.New, Trigger.old);
    } else 
        lt.PopulateAmbassador(Trigger.New, Trigger.old);   
        
    if (Trigger.isBefore && Trigger.isUpdate){
        lt.CreateLastVisitTask(Trigger.new);
        lt.CopyHistoryLog(Trigger.new, Trigger.oldMap);   
    }
}

 
Hi Everyone, 

I need help in making sense of this Apex class that was created years ago in our org. 

Today we ran into an Apex script unhandled exception 

Failed to process batch for class 'VolumeMarketBatch' 

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.VolumeMarketBatch.execute: line 36, column 1

line 36 below is: 
a.Volume_Market__c = pc.Volume_Market__c;​​​​​​​

Any help is greatly appreciated. 

Thank you

 
global with sharing class VolumeMarketBatch implements Database.batchable<sObject> {

	
	global Database.QueryLocator start(Database.BatchableContext info) {

		// Go through and get the list of volume market that has changed
		String returnQuery = 'select Id, Remodeler_Account__c, Postal_Code__c ' +
							 '	from Zip_Assignment__c ' +  
							 '	where Postal_Code__r.Volume_Market_Update__c = true';

        return Database.getQueryLocator(returnQuery); 
   
	}
	
	global void execute(Database.BatchableContext info, List<sObject> sobjectList) {
		// Gets the account and postal codes that have changed
		List<Id> accountIdList = new List<Id>();
		List<Id> pcIdList = new List<Id>();
		for (sObject obj : sobjectList) {
			Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
			accountIdList.add(zipAssign.Remodeler_Account__c);
			pcIdList.add(zipAssign.Postal_Code__c);
		}
		
		// Goes through the accounts and postal codes that have changed and sets the Volume Market field on the account
		Map<Id, Account> accountList = new Map<Id, Account>([select Id, Volume_Market__c from Account where Id = : accountIdList]);
		Map<Id, Postal_Code__c> pcList = new Map<Id, Postal_Code__c>([select Id, Volume_Market_Update__c, Volume_Market__c from Postal_Code__c where Id = : pcIdList]);
		
		for (sObject obj : sobjectList) {
			Zip_Assignment__c zipAssign = (Zip_Assignment__c) obj;
			Account a = accountList.get(zipAssign.Remodeler_Account__c);
			Postal_Code__c pc = pcList.get(zipAssign.Postal_Code__c);
			//System.Debug(pc.Volume_Market__c + a.Volume_Market__c);
			if (pc != null) { 
				if (pc.Volume_Market__c != null) {
					a.Volume_Market__c = pc.Volume_Market__c;
				}
				pc.Volume_Market_Update__c = false;
			}
		}
		
		// updates both account and postal codes
		upsert accountList.values();
		upsert pcList.values();
	}
	
	global void finish(Database.BatchableContext info) {
		
	
	}

}

 
I’m trying to delete a scheduled apex batch job using the syntax below. However, the syntax will delete all scheduled apex jobs, is it possible to delete just 1 scheduled job and if possible, what would the syntax look like?
 
SELECT CreatedDate,CronExpression,CronJobDetailId,Id,NextFireTime,OwnerId.Name,PreviousFireTime,StartTime,State,TimesTriggered FROM CronTrigger

 
Hello, 
Need some help with creating an Apex Test Class for this Apex Class I created which populates a custom object's country field's as either Canada or United States. I attempted to start creating the Apex Test Class but ended up not being able to create it. 
 
global class PostalCodeUtils {
  public static String getPCCountry(String postalCode){
    if (postalCode == null ||  postalCode.length() <= 1){
      return 'United States';
    }
    if (!postalCode.trim().left(1).isNumeric()) {
      return 'Canada';
    } else {
      return 'United States';
    }
  }
  
  public static String getPCID(String postalCode, String pcCountry){ 
    if (postalCode == null){
      return '';
    }
    
    if (pcCountry == 'Canada'){
      if (postalCode.length() >= 3){
        return postalCode.substring(0, 3).toUpperCase();
      }  
    } else {
      if (postalCode.length() >= 5){
        return postalCode.substring(0, 5);
      }
      
    }
    return postalCode; 
    
  }
}

This is my attempt in creating the Apex Test Class (generic Salesforce template): 
@isTest
private class PostalCodeUtilss {
	
	@isTest static void test_method_one() {
		// Implement test code
	}
	
	@isTest static void test_method_two() {
		// Implement test code
	}
	
}
Any ideas? Please let me know. 

 
I've followed the documentation from the Lightning Components Developer Guide on Dynamically Showing or Hiding Markup using a component, js controller and style elements. I was able to place the button on my lightning home page, however, when I click the button, the sample text does not disappear as shown. 

Has anyone run into this problem or is there something missing that wouldn't toggle the sample text provided?

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_show_hide_markup.htm

Component
<!--c:toggleCss-->
<aura:component>
    <lightning:button label="Toggle" onclick="{!c.toggle}"/>
    <p aura:id="text">Now you see me</p>
</aura:component>

js controller
/*toggleCssController.js*/
({
    toggle : function(component, event, helper) {
        var toggleText = component.find("text");
        $A.util.toggleClass(toggleText, "toggle");
    }
})

style
/*toggleCss.css*/
.THIS .toggle {
    display: none;
}

 
  • September 06, 2018
  • Like
  • 0
Hello, 

I've managed to create a custom page for salesforce mobile through the lightning app builder. However,when naming the app page, for example My Salesforce, is there a way to hide this header part using the display:none syntax? If so, where could I hide this header using css? 

User-added image
User-added image

Hi guys  I need to remove customer portal user from standard user look field and only show User and Partner user.Can you please suggest some solution to achieve it.
I want to display around 40k markers on the map. I tried like this but maximum is 10 (i read in documentation this is some sort of a limitation).

Here is my code: 
<apex:page standardController="Account" recordSetVar="accounts" >

  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="42.23  42.23">
        <apex:repeat value="{! accounts }" var="acc">
        <apex:mapMarker title="{! acc.Name }" position="{!acc.BillingLatitude}, {!acc.BillingLongitude},{!acc.BillingCity}, {!acc.Billing_Zip_Postal_Code__c}" />
        </apex:repeat>
  </apex:map>
  </apex:page>

Is there any posibility to do that ? 
  • March 28, 2019
  • Like
  • 1
Hey guys,

i am not familar with javascript, but i really like how the chart.js libary looks. To get started i want to create some cool Salesforce Dashboards with chart.js. I have already create a visualforce Page to show a simple bar chart. Now, i am looking for a way to get the controller variable to the javascript function : 
http://www.chartjs.org/docs/latest/

This is the javascript Code: 
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
    type: 'bar',
    data: {
        labels: ["M1", "M2", "M3", "M4", "M5", "M6"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],   
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});
</script>
How can i change the label and dataset with controller variables ? My idea is to create a simple list and transform the list to string. Does this work ? 

Thanks for help guys. I cant find any help for chart.js and visualforce...

Greetings,

Marry





 
Hi Everyone,

I have been trying to create an email notiication to task assignee upon a new attachment is uploaded to the task.
I created a checkbox field in activites called "Send_Attachment_Email__c".
If this checkbox is true, then a workflow to fire the email notification will be run.

However, I have a problem in the trigger to check the checkbox to true when an attachment is uploaded to task.
Can anybody help me?
 
trigger attachmentTrig on Attachment (after insert) {
  // 1. Get List of Object Ids to notify on
    Set<Id> objectIds = new Set<Id>();

     
    // 2. Loop through list of attachments on Task
    for(Attachment a:trigger.new){

         String keyPrefix = a.ParentId;
         if(keyPrefix == 'Task'){
            objectIds.add(a.ParentId);
         }
    }

     
    // 3. Set the Send Attachment Notification Email field to True
    if(objectIds.size() > 0){

        List<Task> TaskList = [SELECT Id FROM Task WHERE Id IN :objectIds];
         
        for(Task obj:TaskList){
            obj.Send_Attachment_Email__c = true;
        }
      
        if(TaskList.size() > 0){
            update TaskList;
        }      
    }    
}

 
Hi All,

I need a help regarding Custom Settings.In Contact we have fields like Firstname,lastname,Email,City etc.So i will store this specified fields in a custom settings (because in future these fields may be change so storing in custom setting )So whenever only this specified field values are updated in contact then only i need to create a record into another object .If other fields are updated it shouldnot trigger.I am not sure how to compare these field changes through Custom Settings and object Contact.

Anyone can give me some idea to get this scenario done.

Thanks in advance
Hi 
I am planning to give DEV401 Salesforce certification in next week.
Can you please tell which exam to be register for that

 
public PageReference sendEmail(){
        
        try{ 
            if(String.isBlank(toEmail)) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please enter To Address'));
                
                return null;
            }
            if(String.isBlank(subject)) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please enter Subject'));
                        return null;                
            }
Hi,

I have a VisualForce component that presents a SelectList of TimeZones using a jQuery dialog. I have used an "onChange" event on the SelectList with action support that attempts to return the selected value using action support.

All seems to work ok, but the selected time zone does not appear to be set; at least it comes through as a null on the setter. 

I have tried all kinds of things but cannot get this to work properly - - I have used this technique successfully elsewhere, though not in a component.

Here are the relevant code excerpts:

The component
 
<apex:component controller="TimeZonePickerController">

    <apex:includeScript value="{!URLFOR($Resource.jQuery, 'jquery-ui-1.12.1.custom/external/jquery/jquery.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.jQuery, 'jquery-ui-1.12.1.custom/jquery-ui.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.jQuery, 'jquery-ui-1.12.1.custom/jquery-ui.css')}"/>
    

	<script>
    	// Create a new alias for jQuery (j$)
		var j$ = jQuery.noConflict();
	    
	    // When document loaded show the dialog
        j$(document).ready(function(){        
            j$("#dialog").dialog(
            {
                title:"Select a Time Zone",
                autoOpen: false,							
                width:510,
                height:70,
                modal:true,
                closeable:false,
                resizable:false,
                draggable:true
            });
            
            j$("#dialog").dialog('open');					
        }); 


        function closeTheDialog() {
            j$('#dialog').dialog('close');
        }


        function tzChanged(chosenTz) {    

	        // Perform the action - call to Apex
            doAction();
                                    
            // Close the dialog
            closeTheDialog();

        }            

	</script>

	<apex:attribute name="attrTimePickerData"
	    				assignTo="{!theData}"
	    				description=""
	                    type="TimePickerData"/>

                    
	<div id="dialog"> 
		<apex:outputPanel >	
			 
			<apex:selectList id="TimeZone" value="{!selectedTimeZoneStr}" size="1" onchange="tzChanged(this);">
				<apex:selectOptions value="{!TimeZones}"/>
			</apex:selectList>
 			
			<apex:actionFunction name="doAction" action="{!selectTz}"/>
								
		</apex:outputPanel>
	</div>
			
</apex:component>

The component controller:
public with sharing class TimeZonePickerController {

	public TimePickerData theData;
	public List<SelectOption> TimeZones {get; set;} 
	public String selectedTimeZoneStr; 
	private boolean timeZonesFetched = false;			

	public TimeZonePickerController() {
	}

	public TimePickerData getTheData() {
		return theData;		
	}

	public void setTheData(TimePickerData argTheData) {
		theData = argTheData;
		
		// Establish time picker settings for the given type 
		// (Using setter because it is the first time the class TimePickerData is populated)
		buildTimeZoneList();
		
		// Default timezone to user's if not already set
		if (string.isNotBlank(theData.selectedTimeZoneStr)) {
			selectedTimeZoneStr = theData.selectedTimeZoneStr;							
		} else {
			selectedTimeZoneStr = UserInfo.getTimeZone().getID();
		}			
	}	
	
	public String getSelectedTimeZoneStr() {
		return selectedTimeZoneStr;
	}

	public void setSelectedTimeZoneStr(String argSelectedTimeZoneStr) {
	
system.debug('---------- TZ PICKER COMPONENT - setSelectedTimeZoneStr: Start - Value: ' + argSelectedTimeZoneStr);
	
		selectedTimeZoneStr = argSelectedTimeZoneStr;
	
system.debug('---------- TZ PICKER COMPONENT - setSelectedTimeZoneStr - Value: ' + argSelectedTimeZoneStr);
			
		// Set the TimeZone as string and Timezone for return to calling page
		theData.selectedTimeZoneStr = selectedTimeZoneStr;									
//		theData.selectedTimeZone = TimeZone.getTimeZone(theData.selectedTimeZoneStr);									

system.debug('---------- TZ PICKER COMPONENT - setSelectedTimeZoneStr: End');
	}	

    public PageReference selectTz()
    {
		// Close the dialog - does this work?
		theData.displayTzPicker = false;

system.debug('---------- TZ PICKER COMPONENT - selectTz - Str value: ' + selectedTimeZoneStr);
system.debug('---------- TZ PICKER COMPONENT - selectTz - The Data value: ' + theData.selectedTimeZoneStr);
    
        return null;
    
    }

    public void buildTimeZoneList() {
    	
    	// Already fetched?
    	if (timeZonesFetched) {
    		return;
    	}

		// Build timezones
		TimeZones = new List<SelectOption>();
		Schema.DescribeFieldResult fieldResult = User.TimeZoneSidKey.getDescribe();			// Descibes the field in an object  (User in this case)
		List<Schema.PicklistEntry> PkListEntry = fieldResult.getPicklistValues();			// Returns the picklist options
		for( Schema.PicklistEntry  pkEnt : PkListEntry) {
			TimeZones.add(new SelectOption(pkEnt.getValue(), pkEnt.getLabel()));
		}       

		timeZonesFetched = true;


    }
	
}

NB: The component was working perfectly until I turned into a jQuery modal dialog!


 
Hi,
I need your help with the point calculation below.  How do I modify the formula so that when StageName is
Discovery should be 1 Point,
Consensus 1.5,
Evluation 1.5,
Justification 1.5,
Negotiate 1.5 ,
Won 1.5.
Currently, it's defaulting points on above stages to 1. 

Below formula is working great but needed add additional stages to 1.5 points.

IF(ISPICKVAL([Opportunity].StageName , "7 Closed Lost") && ISPICKVAL([Opportunity].Lost_Reason__c , "Duplicate Opp"), 0, 
IF(ISPICKVAL([Opportunity].StageName , "7 Closed Lost" )&&
ISPICKVAL([Opportunity].Count__c ,"<200"), 1,

IF(ISPICKVAL([Opportunity].StageName , "7 Closed Lost") &&
ISPICKVAL([Opportunity].Count__c , "200 - 999"),1.5,

IF(ISPICKVAL([Opportunity].StageName , "7 Closed Lost" )&&
ISPICKVAL([Opportunity].Count__c ,"1000+") ,2,

IF(!ISPICKVAL([Opportunity].StageName , "7 Closed Lost" )&&
ISPICKVAL([Opportunity].Count__c ,"<200"), 1,

IF(!ISPICKVAL([Opportunity].StageName , "7 Closed Lost") &&
ISPICKVAL([Opportunity].Count__c , "200 - 999"),1.5,

IF(!ISPICKVAL([Opportunity].StageName , "7 Closed Lost" )&&
ISPICKVAL([Opportunity].Count__c ,"1000+") ,2,

IF(AND(!ISPICKVAL([Opportunity].StageName , "7 Closed Lost" ),
 !ISPICKVAL([Opportunity].Lost_Reason__c , "Duplicate Opp"),
ISPICKVAL([Opportunity].Count__c ,"")), 1,
0))))))))
I need a routine for import of child records to Contacts.  Custom fields for Custom Object and Contact have been created, and are config as External ID.  Import wizard only permits one child per parent and views any additional records as duplicates :(

Workflow/Validation rule won't work, as the field to update is LookUp to Contact.

Can I initiate a process from a view, to look up contact id based on matching values in the custom field?
IF (CustomObject__c.CustomField__c = Contact__r.CustomField__c) TRUE place Contact.ID in lookup field, FALSE leave generic contact ID inplace)
 
  • August 23, 2016
  • Like
  • 1
Web to Lead form is not allowing us to make a field mandatory.  Lloyd from SF was working on this but I haven't herard back from him in a few days ref:_00D0062._5000Mf030k:
There is no actual superbadge you can download or display on LinkedIn when you earn one.  Just finished my Reports and Dashboards superbadge, and there was nothing.  What a waste. 
Hi friends,

I am writing sum trigger between two custom objects and program is saved but not executed properly like argument can't be null here i am passing values but it throws an error
 Trigger sum_of_amount on Employee__c(after insert,after update,after delete,after undelete)
 {
 List<Department__c> dept_amount=new List<Department__c>();
 set<id> Dept_id=new set<id>();
 for(Employee__c emp:trigger.new)
 {
 Dept_id.add(emp.deptid__c);
 }
 Decimal adding_amount;
 for(Department__c dept:[select id,deptname__c,(select id,EmpName__c,EmpSal__c from Employees__r) 
 from Department__c where id in:dept_id])
 {
 adding_amount=0;
 for(Employee__c emplist:dept.Employees__r)
 {
 system.debug('My Emp Salary value is +++++===='+emplist);
 adding_amount+=emplist.EmpSal__c;
 system.debug('Newly adding value is========++++++'+adding_amount);
 }
 dept.Total_amount__c=adding_amount;
 dept_amount.add(dept);
 }
 update dept_amount;
 }
I'm very new to javascript and looking for help on a button.  It's a custom "Take Ownership" button for cases but I'm looking to do two extra things:  1.  Pop up a confirm box if the owner is not null or a queue.  I'd also like to insert the owner's full name into the confirm box if possible.  (The intent here is to warn a user that someone has already taken ownership of this case if/when that happens.)  I'm missing a few things:

{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 

if(
 AND(
{!Case.OwnerFullName} <> "", 
{!Case.OwnerFullName} <> "Support Tier 1", 
{!Case.OwnerFullName} <> "Support Tier 2", 
{!Case.OwnerFullName} <> "Support Tier 3", 
{!Case.OwnerFullName} <> "Billing Queue", 
{!Case.OwnerFullName} <> "Customer Success", 
{!Case.OwnerFullName} <> "Customer Queue")){

if(confirm('This case is already assigned.  Are you sure you want to take ownership?')){ 

var updateRecord = new Array(); 
var myquery = "SELECT Id FROM Case WHERE Id = '{!Case.Id}' limit 1";

result = sforce.connection.query(myquery);
records = result.getArray("records");

if(records[0])
{
    var update_Case = records[0];
    update_Case.OwnerId = "{!$User.Id}"; 
    update_Case.Status = "Active";
    updateRecord.push(update_Case);

result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;
}
else {
alert("Error saving case: " + result[0]);
}
}
}
I'm trying to get the activity records whose RelatedTo is of type Account in order to update Total_Touches field on Account. Somehow it is not getting the Activity records and I'm not getting any error. Below is my code, Any advice please?


    public static set<Id> filterTaskOrEventRecords(List<sObject> lstActivities,map<Id,sObject> mapOldActivities)
    {
        set<Id> setAccountIds = new set<Id>();

        for(sObject objActivity : lstActivities)  
        {
            Boolean isRelatedToCompany = objActivity.get('AccountId') != null ? (((Id)objActivity.get('AccountId')).getsObjectType() == Account.sObjectType ? true : false) : false;
             
            // Filtering records in insert,update and delete case.
            if((trigger.isInsert) || (trigger.isDelete) || trigger.isUpdate)
            {
                 if(isRelatedToCompany) 
                    setAccountIds.add((Id)objActivity.get('AccountId'));
                
                 if( trigger.isUpdate && ((Id)mapOldActivities.get(objActivity.Id).get('AccountId')).getsObjectType() == Account.sObjectType)    
                     setAccountIds.add((Id)mapOldActivities.get(objActivity.Id).get('AccountId'));
            }
        }
        return setAccountIds;
    }
Hii guys please help me to solve this task :
To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).
Name the validation rule 'Contact must be in Account ZIP Code'.
A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.
The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)
 
HI Developers,

I have an urgent Requirement , Please see the below requirement and let me know various possibiliteis to achieve my Task,

Create a report to display all users,( how many licenses of each type we have available and how many we have purchased, but we can't run a user report to find out which users are in which license type.)

I have to show report like this and i also scheduled every month 1st week to generate report and send email to administrator

User-added image
Thanks in Advance
  Hanu
 
I have a picklist field 'address type' values are us ,canada and foreign.If I select US and Canada the billing state should show list of predefined values and for ,address type' is selected as foreign the billing state should be text field and should be able to enter any value.We are using visual force pages.Please help me on this
Hi,

I have a custom object with 2 global picklists on it. These are then marked as dependant.
When I edit the record on a standard page the dependant picklists work correctly.
When I edit the record from a visualforce page the dependant picklist is read only and looks empty.

I have checked the permissions, its via the admin profile and every thing is definately turned on and editable. 
I can't see why it wouldn't work. If I remove the dependancy the both fields are editable again on the visualforce page.

Thanks
Sarah