• Mohammed Haseeb
  • NEWBIE
  • 30 Points
  • Member since 2014
  • Technical consultant
  • Makepositive


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 3
    Replies
HI,

I am getting this error, can anyone help?: -

System.NullPointerException: Attempt to de-reference a null object: Trigger.NickMiramsTaskLeadUpdate: line 30, column 1

heres the code...I am trying to write a trigger to close a task as 'Completed' after a lead status becomes Closed Lost or Qualified...

trigger NickMiramsTaskLeadUpdate on Lead (after update){

set<id> leadids = new set<id>();
map<id,list<task>> leadtotaskmap = new map<id,list<task>>();
list<task> taskstoupdate = new list<task>();
for(lead Lead : trigger.new){
leadids.add(lead.id);
}

list<task> tasklist = [select whatid,status from task where whatid in : leadids];

for(task t : tasklist){
if(leadtotaskmap.get(t.whatid)!=null){
list<task> temp = leadtotaskmap.get(t.whatid);
temp.add(t);
leadtotaskmap.put(t.whatid, temp);
}
else
{
leadtotaskmap.put(t.whatid, new list<task>{t});
}

}

for(lead lead : trigger.new){
if(lead.status=='Closed Lost' || lead.status=='Qualified'){

list<Task> tasklisttemp = leadtotaskmap.get(lead.id);

for(task t : tasklisttemp){

    t.status='completed';
taskstoupdate.add(t);
}
   

}

}

if(taskstoupdate.size()>0)
update taskstoupdate;

}
HI,

I am getting this error, can anyone help?: -

System.NullPointerException: Attempt to de-reference a null object: Trigger.NickMiramsTaskLeadUpdate: line 30, column 1

heres the code...I am trying to write a trigger to close a task as 'Completed' after a lead status becomes Closed Lost or Qualified...

trigger NickMiramsTaskLeadUpdate on Lead (after update){

set<id> leadids = new set<id>();
map<id,list<task>> leadtotaskmap = new map<id,list<task>>();
list<task> taskstoupdate = new list<task>();
for(lead Lead : trigger.new){
leadids.add(lead.id);
}

list<task> tasklist = [select whatid,status from task where whatid in : leadids];

for(task t : tasklist){
if(leadtotaskmap.get(t.whatid)!=null){
list<task> temp = leadtotaskmap.get(t.whatid);
temp.add(t);
leadtotaskmap.put(t.whatid, temp);
}
else
{
leadtotaskmap.put(t.whatid, new list<task>{t});
}

}

for(lead lead : trigger.new){
if(lead.status=='Closed Lost' || lead.status=='Qualified'){

list<Task> tasklisttemp = leadtotaskmap.get(lead.id);

for(task t : tasklisttemp){

    t.status='completed';
taskstoupdate.add(t);
}
   

}

}

if(taskstoupdate.size()>0)
update taskstoupdate;

}
My page:
------------
<apex:page controller="MonthYearpicklistcontroller">
  <apex:form >
  <apex:pageBlock >
  <apex:selectList size="1" value="{!myDateRange}">
     <apex:selectOptions value="{!DateRangeOptions}"/>
     <apex:actionSupport event="onchange" reRender="out1"/>
</apex:selectList>
<apex:commandButton value="Go" action="{!doAction}" />
<apex:pageBlockSection rendered="{!isBoolean}">
          <ul>
        <apex:outputLabel value="Account:">
        <apex:repeat value="{!accounts}" var="account">
       
            <li>
                {!account.Name}
               
                <ul>
                <apex:outputLabel value="Opportunity:">
                <apex:repeat value="{!account.children}" var="opportunity">
                    <li>
                        {!opportunity.Name}
                        
                        <ul>
                        <apex:outputLabel value="Contact:">
                        <apex:repeat value="{!opportunity.children}" var="contact">
                            <li>
                                {!contact.Name}
                            </li>
                        </apex:repeat>
                        </apex:outputLabel>
                        </ul>
                        
                    </li>
                </apex:repeat>
                </apex:outputLabel>
                </ul>
                
            </li>
        </apex:repeat>
        </apex:outputLabel>
        </ul>
       

</apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

My Controller:
----------------

public class MonthYearpicklistcontroller {
    public Boolean isBoolean { get; set; }
    public String myDateRange { get; set; }
   
    public List<SelectOption> getDateRangeOptions() {

        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('1-2014','Jan-2014'));
        options.add(new SelectOption('2-2014','Feb-2014'));
        options.add(new SelectOption('3-2014','Mar-2014')); `enter code here`
        options.add(new SelectOption('4-2014','Apr-2014'));
        options.add(new SelectOption('5-2014','May-2014'));
        options.add(new SelectOption('6-2014','june-2014'));
        options.add(new SelectOption('7-2014','july-2014')); 
        options.add(new SelectOption('8-2014','Aug-2014'));
        options.add(new SelectOption('9-2014','Sep-2014'));
        options.add(new SelectOption('10-2014','Oct-2014'));
           return options; 
    }
     public List<Wrapper> accounts{
        get
        {
         
       
            List<Wrapper> accounts = new List<Wrapper>();
            List<Id> oppIds = new List<Id>();
            for(Account acc : [Select Id, Name, (Select Id, Name From Opportunities) From Account])
            {
                Wrapper account = new Wrapper();
                account.Id = acc.Id;
                account.Name = acc.Name;
                account.children = new List<Wrapper>();
                accounts.add(account);
                for(Opportunity opp : acc.Opportunities)
                {
                    Wrapper opportunity = new Wrapper();
                    opportunity.Id = opp.Id;
                    opportunity.Name = opp.Name;
                    opportunity.children = new List<Wrapper>();
                    account.children.add(opportunity);
                    oppIds.add(opp.Id);
                }
            }
            Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>([Select Id, (Select Id, Contact.Name From OpportunityContactRoles) From Opportunity where id In :oppIds]);
            for(Wrapper account : accounts)
            {
                for(Wrapper opportunity : account.children)
                {
                    for(OpportunityContactRole opCR : oppMap.get(opportunity.Id).OpportunityContactRoles)
                    {
                        Wrapper contact = new Wrapper();
                        contact.Id = opCR.Id;
                        contact.Name = opCr.Contact.Name;
                        opportunity.children.add(contact);
                    }
                }
            }
            return accounts;
        }
    }
   
   
     public PageReference doAction() {
     isBoolean =true;
        return null;
    }
   
     public class Wrapper{
        public Id Id{get;set;}
        public String Name{get;set;}
        public List<Wrapper> children{get;set;}
    }

}

How to display based on picklist month and date related records?

please help me......
  • October 05, 2014
  • Like
  • 0
Hi There-

We are using Pardot for marketing automation and currrently the sync works from Pardot to Salesforce automatically and from Salesforce to Pardot with a button click that executes a java scrpit that pushes lead basic data to our Pardot instance

**
window.location = 'https://blablabla/email/{!Lead.Email}?lead_id={!Lead.Id}&sessionid={!$Api.Session_ID}&serverurl={!$Api.Partner_Server_URL_90}&redirect_location='+window.location
**
Im requesting for your help to translate this JS to apex which will work every time 1 or more leads are created in salesforce?
Please assist

Maor
Hello,

We are using SOAP call to send information from SFDC to our Target system but sometimes it is taking more than 2 mins(Salesforce governor limit) to get response from target system.

Can we increase the waiting time from salesforce side to more than 2 mins?
  • October 06, 2014
  • Like
  • 1