• prady
  • NEWBIE
  • 80 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 89
    Questions
  • 58
    Replies

I want to automatically convert new leads into contacts. I have a trigger on Lead after update that will bulk convert 100 leads at a time. The problem I have  is that my marketing automation tool pushes new leads into Salesforce in batches of 200 at a time. When I try to import 200 leads, the bulk convert fails due to a too many DML 151 error.

 

I read that the convertlead function can only handle 100 records at a time. How can I edit the code to handle 200 imports at a time? Is it possible?

 

Thanks in advance.

 

trigger AutoConvert on Lead (after update) {

for(Lead myLead: Trigger.new){ if(Trigger.new[0].isConverted == false) { Database.LeadConvert lc = new database.LeadConvert(); lc.setLeadId(myLead.Id); lc.convertedStatus = 'Qualified'; //Database.ConvertLead(lc,true); lc.setDoNotCreateOpportunity(true); Database.LeadConvertResult lcr = Database.convertLead(lc); System.assert(lcr.isSuccess()); }}}

 

Hi all,

 

I have created a report out 3000 leads I have 770 leads with Date of Birth. I want to convert only this 770 leads to contacts.

 

Can anyone please help me with this?

 

Thanks in Advance

 

Cheers

Uma

Hi,

 

On researching on apex scheduler to for scheduling a class for every 10 or 15 mins we would need to write the schedule code in the system log.

 YourScheduleClass c = new YourScheduleClass();
String sch = '0 0 * * * ?';
System.schedule('Schedule Job1', sch, c);

YourScheduleClass c = new YourScheduleClass();
String sch = '0 10 * * * ?';
System.schedule('Schedule Job2', sch, c);

YourScheduleClass c = new YourScheduleClass();
String sch = '0 20 * * * ?';
System.schedule('Schedule Job3', sch, c);

YourScheduleClass c = new YourScheduleClass();
String sch = '0 30 * * * ?';
System.schedule('Schedule Job4', sch, c);

 Would these entries be an one time job on production env? Would it affect anything if i edit/change the times later?

hi,

 

how does upsert work?

my understanding is that it checks if there is a record with unique id and if its available then it updates that record and if its not then inserts it.

 

Am i right?

 

I seem to get an error

Upsert failed. First exception on row 1; first error: DUPLICATE_EXTERNAL_ID, Asset Tag: more than one record found for external id field: [a11M0000000CwJqIAK, a11M0000000CwJvIAK]: [Asset_Tag__c]

 

i have a list with item and they dont have asset tag repeating in that

 

system.debug('LstItem Asset_Tag__c'+LstItem );
		upsert 	LstItem Asset_Tag__c;

 From the debug log

 

LstItem Asset_Tag__c(Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=12149, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 06:08:47}, Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=23157, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 08:26:14})

 You can see that the asset tags are not repeated. So i am not sure from where the duplicate external id is coming

 

Thanks

I need to query an object called trans__c which has the following fields

 

id,

scantime__c // datetime

name

asset__c // external id

status

 

I need to get only data which has status as pending and if there are any repeating asset then i need to get only  record with scantime as the latest.

 

Thanks

 

 

 

Hi,

 

Do governor limits apply when i use a insert using a list.

 

For eg. i add all the records to be inserted in to a list and finally give a insert list. I might have 3000 records in the list

Does it take as one DML statement or does it take as 3000 DML statements?

 

Thanks

 

I have an object called "Lease".When i create a record in Lease  it  gets saved.I should have a button  "Generate Office " in the record which automatically creates an office record which is exactly same as record created earlier in Lease

 

In " office" all the fields which are there in "lease" are present and also they are formula fields

 

 

I am in a confusion as i didnot understand d req properly or how do i need approach

 

 

Do i need to visual force page for the button

Hi,

 

i am trying to assign a string value to text type custom field on line 7 but getting the complier error "Expression cannot be assigned "

 

any idea what i am missing?

 

 

thanks,

ublic class IRPTemplateSelection {

public PageReference TemplateSelection() {
        
        // String TemplateId = 'a0JP0000001qGwU'; 
        String TemplateId = System.currentPageReference().getParameters().get('Templateid');
        Orphan__c.Biodata_Report_Template_4_Conductor__c = TemplateId ;
        
        PageReference pageRef = new PageReference('https://cs4.salesforce.com/a0A?fcf=00B20000005raAO' );
        pageRef.setRedirect(true);

        return pageRef; 

    }
}

 

Hi,

 

I want to send email when a field is updated in a custom object. so i have a trigger written. i also created a email template.

I find that the targetobjectid is a required field while sending an email. Its erroring out where i am setting targeto

bject .Id. It says Save error: Variable does not exist: Lstuser.id

Any ideas what am i doing wrong

trigger change_action on Ticket__c (after update) {
	//List<user>Lstuser= new List<user>();
	List<id> lstid=new List<id>();
	List<string> lstemail= new List<string>();
	Map<id,string> Mapemail = new Map<id,string>();
	

	for(ticket__c t:trigger.new)
	{
		if(trigger.isUpdate)
		{
			if(t.Actions__c!=System.Trigger.oldMap.get(t.Id).Actions__c)
			{
				lstemail.clear();
				lstemail.add(t.Initiator_Email__c);
				lstemail.add(t.Admin_email__c);
				
				for(User Lstuser:[select id, email,username from user where email in :lstemail]);
				{
				List<EmailTemplate> emailtemplatelist = new List<EmailTemplate>();
				emailtemplatelist=[select id, name from EmailTemplate where name='Update on ticket'];
				if (emailtemplatelist.size()>0)
				{
					//emailtemplatelist[0]
					Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
					mail.toAddresses = new string[]{t.Initiator_Email__c,t.Admin_email__c};
					//mail.setToAddresses(t.Initiator_Email__c);
					mail.setTemplateId(emailtemplatelist[0].id);
/**************************Its THROWING ERROR ON BELOW LINE **********************************/ mail.TargetObjectId(Lstuser.id);//ERROR ON THIS LINE Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } } } } } }

 

Hi,

 

I have a few reports created. I want these reports to be viewed by a particular profile. They should not be able to edit it. How can i set these ?

 

Thanks

Prady

Hi,

 

I have a class written and when i move the class to production i get an error. Everything seems to work fine on sandBox.

If i remove the block of code it passes the code to production. I have a almost similar piece of code just

below the erroring code. This works fine and gets passed over into production. Any ideas on what could

be the issue?

 

Failure Message: "System.NullPointerException: Attempt to de-reference a null object", Failure Stack Trace: "Class.AppointmentController.refresh: line 252, column 82 Class.Test_Appointment.Testapp: line 29, column 6 External entry point"

 

Here is my code

 

Public Class AppointmentController
{

    public PageReference createApp() {
    
        return page.Appointment;
    }

Public Appointment__c Appointment { get; set; }
public String Error { get; set; }
public String ClientsSearch { get; set; }
public list<CEventTimeSlot> liETimeSlots {get;set;}
public list<CEventTimeSlot> liETimeSlots_form {get;set;}
public list<CTimeSlot> liTimeSlots {get;set;}
public list<CTimeSlot> liTimeSlots_form {get;set;}
public Map<string,CTimeSlot> mapTimeToSlot {get;set;}
public Map<string,CEventTimeSlot> mapETimeToSlot {get;set;}
public List<String> LstString{get;set;}

Public AppointmentController()
{
Appointment = new  Appointment__c();
}
   


/* function called from VF page for updating the startdatetime and endDatetime  and rendering into VF page   */
   public PageReference refresh() {
    try
      {
         liTimeSlots = new list<CTimeSlot>();
         mapTimeToSlot = new Map<string,CTimeSlot>();
         liTimeSlots_form = new list<CTimeSlot>();
         //For adding Events
         liETimeSlots = new list<CEventTimeSlot>();
         mapETimeToSlot = new Map<string,CEventTimeSlot>();
         liETimeSlots_form = new list<CEventTimeSlot>();
          
          
          
         

        
      if (Appointment.Start_Date__c<>null)
      {
        Time pktime;
        Time pkTime1;
        List<Time> LstTime = new List<Time>();
        pktime=time.newInstance(7,0,0,0);
        LstTime.add(pktime);

        for(integer ctr=0; ctr<30;ctr++)
        {
            pktime=pktime.addMinutes(30);
            LstTime.Add(pkTime);
        }
        system.Debug(' Listtime '+LstTime);
        
        system.debug('No of Time Items'+LstTime.size());
        for(integer ctr1=0; ctr1<LstTime.size();ctr1++)
        {       
        
        CTimeSlot newSlot = new CTimeSlot(string.valueof(LstTime[ctr1]));
        liTimeSlots.add(newSlot);
        
        mapTimeToSlot.put(string.valueof(LstTime[ctr1])+ '', newSlot);
        newSlot=null;
        
        CEventTimeSlot newESlot = new CEventTimeSlot(string.valueof(LstTime[ctr1]));
        liETimeSlots.add(newESlot);
        
        mapETimeToSlot.put(string.valueof(LstTime[ctr1])+ '', newESlot);
        newESlot=null;
        }
        
        
		system.debug('liETimeSlots.....'+liETimeSlots);
		system.debug('mapETimeToSlot.....'+mapETimeToSlot);
        String t_startdatetime_str;
        String t_enddatetime_str;
        integer t_syear;
        
        integer t_smonth;
        integer t_day;
        t_syear=Appointment.Start_Date__c.year();
        t_smonth=Appointment.Start_Date__c.month();
        t_day=Appointment.Start_Date__c.day();
        t_startdatetime_str=t_syear+'-'+t_smonth+'-'+t_day+' 00:00:00';
        datetime t_startdatetime;
        datetime t_enddatetime;
        t_startdatetime=datetime.valueof(t_startdatetime_str);
        t_enddatetime=t_startdatetime.addHours(23);
        t_enddatetime=t_enddatetime.addMinutes(59);
        t_enddatetime=t_enddatetime.addSeconds(59);
        
        
        datetime Ls_startdatetime;
        datetime Ls_enddatetime;
        
        //t_startdatetime=Appointment.Start_Date__c.format();
        system.debug('t_startdatetime'+t_startdatetime);
        
        List<Appointment__c> a=[select id, name,Appointment_Type__c,Status__c,StartDateTime__c,EndDateTime__c,Duration__c, ap.Client_First_Name__c,patient__c,subject__c from Appointment__c ap where   
         (
                                  (ap.StartDateTime__c >= :t_startdatetime  AND ap.StartDateTime__c <= :t_enddatetime) OR
                                  (ap.EndDateTime__c >= :t_startdatetime  AND ap.EndDateTime__c <= :t_enddatetime) OR
                                  (ap.StartDateTime__c <= :t_startdatetime   AND ap.EndDateTime__c >= :t_enddatetime)
                               )];
                               
        List<Event> eve=[select id, subject,StartDateTime,EndDateTime from event eve where   
         (
                                  (eve.StartDateTime >= :t_startdatetime  AND eve.StartDateTime <= :t_enddatetime) OR
                                  (eve.EndDateTime >= :t_startdatetime  AND eve.EndDateTime <= :t_enddatetime) OR
                                  (eve.StartDateTime <= :t_startdatetime   AND eve.EndDateTime >= :t_enddatetime)
                               )];
        
        
        /*Start_Date__c=: Appointment.Start_Date__c order by Start_Date__c asc ] ;*/
        System.debug(eve);
        
        string tshour;
        string tmin;
        string strLs_startdatetime;
        Integer noofslots=0;
        time overLapSlotsTime;
        Integer noofEslots=0;
        time overLapESlotsTime;
        string timeAMPM;
        integer timeHour;
        string timeMin;
        Decimal datediff=0;
        
 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */       
 /*=========================ERRORS OUT IN THIS BLOCK==============================*/ 
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ if (eve.size()>0) { for(integer z=0;z<eve.size();z++) { if(mapETimeToSlot.get(string.valueof(eve[z].StartDateTime.time())) != null) { // system.debug('+++++++++++++++++++++++++++++++++++++duration'+a[z].Duration__c); overLapESlotsTime=eve[z].StartDateTime.time(); datediff=((Decimal.valueOf(eve[z].EndDateTime.getTime()) - Decimal.valueOf(eve[z].StartDateTime.getTime()))/(1000*60*60))*60; system.debug('datediff '+datediff); if(datediff>30) { noofEslots=integer.valueOf((datediff/30)); system.debug('+++++++++++++++++++++++++++++++++++++noofslots'+noofEslots); for(Integer nctr=0;nctr<noofEslots;nctr++) { if(mapETimeToSlot.get(string.valueof(overLapESlotsTime)).sEvent!=null)
//-------------------------------------------------------------------------------------------
//////////////////////////////////////ERRORS ON ABOVE LINE//////////////////////////////////
//-------------------------------------------------------------------------------------------
 { mapETimeToSlot.get(string.valueof(overLapESlotsTime)).sEventOverlap = eve[z]; mapETimeToSlot.get(string.valueof(overLapESlotsTime)).status='Y'; system.debug('++++++++++++++++++++++++++++++++++++inside overlap'); } else { mapETimeToSlot.get(string.valueof(overLapESlotsTime)).sEvent = eve[z]; system.debug('+++++++++++++++++++++++++++++++++outside overlap'); } overLapESlotsTime=overLapESlotsTime.addMinutes(30); } //mapTimeToSlot.get(string.valueof(a[z].StartDateTime__c.time())).sAppointment = a[z]; }else { if(mapETimeToSlot.get(string.valueof(overLapESlotsTime)).sEvent!=null) { mapETimeToSlot.get(string.valueof(eve[z].StartDateTime.time())).sEventOverlap = eve[z]; } else { mapETimeToSlot.get(string.valueof(eve[z].StartDateTime.time())).sEvent = eve[z]; } } } } } /*=========================================================================================*/
/********************************************THIS BLOCK BELOW WORKS********************************/
/*===========================================================================================*/


if (a.size()>0) { for(integer z=0;z<a.size();z++) { if(mapTimeToSlot.get(string.valueof(a[z].StartDateTime__c.time())) != null) { system.debug('+++++++++++++++++++++++++++++++++++++duration'+a[z].Duration__c); overLapSlotsTime=a[z].StartDateTime__c.time(); datediff=((Decimal.valueOf(a[z].EndDateTime__c.getTime()) - Decimal.valueOf(a[z].StartDateTime__c.getTime()))/(1000*60*60))*60; system.debug('datediff '+datediff); if(datediff>30) { noofslots=integer.valueOf((datediff/30)); system.debug('+++++++++++++++++++++++++++++++++++++noofslots'+noofslots); for(Integer nctr=0;nctr<noofslots;nctr++) { system.debug('+++++++++++++++++++++++++++++++++++++overLapSlotsTime'+overLapSlotsTime); if(mapTimeToSlot.get(string.valueof(overLapSlotsTime)).sAppointment!=null) { mapTimeToSlot.get(string.valueof(overLapSlotsTime)).sAppointmentOverlap = a[z]; mapTimeToSlot.get(string.valueof(overLapSlotsTime)).status='Y'; system.debug('++++++++++++++++++++++++++++++++++++inside overlap'); } else { mapTimeToSlot.get(string.valueof(overLapSlotsTime)).sAppointment = a[z]; system.debug('+++++++++++++++++++++++++++++++++outside overlap'); } overLapSlotsTime=overLapSlotsTime.addMinutes(30); } //mapTimeToSlot.get(string.valueof(a[z].StartDateTime__c.time())).sAppointment = a[z]; }else { if(mapTimeToSlot.get(string.valueof(overLapSlotsTime)).sAppointment!=null) { mapTimeToSlot.get(string.valueof(a[z].StartDateTime__c.time())).sAppointmentOverlap = a[z]; } else { mapTimeToSlot.get(string.valueof(a[z].StartDateTime__c.time())).sAppointment = a[z]; } } } } } /*============================================================================================== for(integer lictr=0;lictr<liETimeSlots.size();lictr++) { system.debug('inside transfer of liETimeSlots to Formated List'); timeAMPM=liETimeSlots[lictr].tstart1.substring(0,5); timeHour=integer.valueof(timeAMPM.substring(0,2)); timeMin=timeAMPM.substring(2,5); system.debug('time hour value'+timeHour); system.debug('time hour value'+timeMin); if (timeHour>12) { timeHour=timehour-12; system.debug('timeHour++++++++++++++++++++++++++'+timeHour) ; timeAMPM=string.valueof(timeHour); if (timeAMPM.length()==1) { timeAMPM='0'+timeAMPM+timeMin+' PM'; } else { timeAMPM=timeAMPM+timeMin+' PM'; } } else { timeAMPM=string.valueof(timeHour); if (timeAMPM.length()==1) { timeAMPM='0'+timeAMPM+timeMin+' AM'; } else { timeAMPM=timeAMPM+timeMin+' AM'; } } liETimeSlots[lictr].tstart1=timeAMPM; //liTimeSlots_form[lictr].sAppointment=liTimeSlots[lictr].sAppointment; } system.debug('liETimeSlots++++++++++++++++++++++++'+liETimeSlots); /*============================================================================================*/ for(integer lictr=0;lictr<liTimeSlots.size();lictr++) { system.debug('inside transfer of liTimeSlots to Formated List'); timeAMPM=liTimeSlots[lictr].tstart1.substring(0,5); timeHour=integer.valueof(timeAMPM.substring(0,2)); timeMin=timeAMPM.substring(2,5); system.debug('time hour value'+timeHour); system.debug('time hour value'+timeMin); if (timeHour>12) { timeHour=timehour-12; system.debug('timeHour++++++++++++++++++++++++++'+timeHour) ; timeAMPM=string.valueof(timeHour); if (timeAMPM.length()==1) { timeAMPM='0'+timeAMPM+timeMin+' PM'; } else { timeAMPM=timeAMPM+timeMin+' PM'; } } else { timeAMPM=string.valueof(timeHour); if (timeAMPM.length()==1) { timeAMPM='0'+timeAMPM+timeMin+' AM'; } else { timeAMPM=timeAMPM+timeMin+' AM'; } } liTimeSlots[lictr].tstart1=timeAMPM; //liTimeSlots_form[lictr].sAppointment=liTimeSlots[lictr].sAppointment; } } } }

 

public with sharing class CEventTimeSlot {
	

	
	// public Time           tStart         {get; set;}
	public string status {get;set;}
	 public String tStart1 {get; set;}
    public Event sEvent {get; set;}
    public Event sEventOverlap {get; set;}

    public CEventTimeSlot(String startTime)
    {
        tStart1 = startTime;
        status='';
        sEvent = null;
        sEventOverlap=null;
    }



}

 

public with sharing class CTimeSlot {
	
	// public Time           tStart         {get; set;}
	public string status {get;set;}
	 public String tStart1 {get; set;}
    public Appointment__c sAppointment {get; set;}
    public Appointment__c sAppointmentOverlap {get; set;}

    public CTimeSlot(String startTime)
    {
        tStart1 = startTime;
        status='';
        sAppointment = null;
        sAppointmentOverlap=null;
    }

}

 

Hi,

 

I am writing a trigger on update but  i get this error

Save error: Initial term of field expression must be a concrete SObject: LIST<QuoteLineItem>.

I am not sure what is causing this. Here is my code

 

trigger Update_Discount_on_QuoteLineItem on Quote (after update) {
	
	List <QuoteLineItem> QLI = new List <QuoteLineItem>();
	Map<id,double> MapSoftwareDiscount= new Map <id,double>();
	Map<id,double> MapHardwareDiscount= new Map <id,double>();
	Set <id> Qid= new Set<id>();
	
	for (Quote  Q: Trigger.new)
	{
		if (Q.Software_Discount__c!=System.Trigger.oldMap.get(Q.Id).Software_Discount__c ||Q.hardware_Discount__c!=System.Trigger.oldMap.get(Q.Id).hardware_Discount__c )
		{
			Qid.add(Q.id);
			MapSoftwareDiscount.put(Q.id,Q.Software_Discount__c);
			MapHardwareDiscount.put(Q.id,Q.hardware_Discount__c);
			
		}
	}
	
	QLI=[select id,QuoteId,product_category__c,Discount from QuoteLineItem where QuoteId in :Qid];
	for(integer i=0; i <QLI.size();i++)
	{
		if (QLI[i].product_category__c=='Software')
		{
			QLI[i].Discount=MapSoftwareDiscount.get(QLI.QuoteId); //ERRORS OUT HERE
		}
		else if(QLI[i].product_category__c=='Hardware')
		{
			QLI[i].Discount=MapHardwareDiscount.get(QLI.QuoteId);
		}
	}
	update QLI;
	
	

}

 

Any ideas what is causing this

 

I have a VF page which has a popup to accept a few fields.

When I run the page and fill in the fields, I can see that only some field values are getting captured, others are returining as null. I cross checked the field names, they are the same. Any ideas why this could happen?



<apex:outputPanel id="tstpopup1">
        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
            <apex:pageblock >
                <apex:pageblocksection >
                    <apex:pageblocksectionitem >
                    <apex:outputlabel value="Project: " />
                    <apex:inputfield id="proj" value="{!AC.Project__c}" />
                    </apex:pageblocksectionitem><p/>
                    <apex:pageblocksectionitem >
                    <apex:outputlabel value="Start Date: " />
                    <apex:inputfield id="sd" value="{!AC.Start_Date__c}" />
                    </apex:pageblocksectionitem>
                    <apex:pageblocksectionitem >
                    <apex:outputlabel value="End Date: " />
                    <apex:inputfield id="ed" value="{!AC.End_Date__c}" />
                    </apex:pageblocksectionitem>
                    <apex:pageblocksectionitem >
                    <apex:outputlabel value="C85 Project Lead: " />
                    <apex:inputfield id="pl" value="{!AC.C85_Project_Lead__c}" />
                    </apex:pageblocksectionitem>
                    <apex:pageblocksectionitem >
                    <apex:outputlabel value="Daily Charge Rate of Consultant: " />
                    <apex:inputfield id="charge" value="{!AC.Daily_Charge_Rate_of_Consultant__c}" />
                    </apex:pageblocksectionitem>
                    <apex:pageblocksectionitem >
                    <apex:outputlabel value="Project Role Title: " />
                    <apex:inputfield id="role" value="{!AC.Project_Role_Title__c}" />
                    </apex:pageblocksectionitem>
                    <apex:pageblocksectionitem >
                    <apex:outputlabel value="Overtime Allowed: " />
                    <apex:inputfield id="overtime" value="{!AC.overtime_allowed__c}" />
                    </apex:pageblocksectionitem>
                    </apex:pageblocksection>
                    <apex:commandbutton value="Assign to a New Project" action="{!assign}"   />
                    <apex:commandbutton value="Cancel" action="{!closePopup}" immediate="true" /><br/><br/><br/>
                    </apex:pageblock>
            </apex:outputPanel>

 

    public Assigned_Consultant__c AC{
        get{
            if (AC == null) AC = new Assigned_Consultant__c();
            return AC;
        }
        set; 
    }


public PageReference assign()
{ 
system.debug('Role title ...........................' + AC.Project_Role_Title__c); // this is returning null
            system.debug('Day charge ...........................' + AC.Daily_Charge_Rate_of_Consultant__c); this has value filled
system.debug('overtime_allowed__c ...........................' + AC.overtime_allowed__c);  // this is returning null


         // Project_Role_Title__c
            displayPopup = false;  
            system.debug('inside assign...........................3');
            system.debug('AC.................' + AC);   

  }