• DennisYZF
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies

OK, so here is my first time asking for help here - below is a trigger on lead, it should query a custom object, and if a match is found, update a lookup field on the lead with the custom object id - Works 100% in Sandbox, fails in production(does not populate all leads in a batch with matching custom object IDs, only about 70%)! Any recommendations?

Thanks!

 

 

trigger LeadSourceRef on Lead( before insert ) {

String DotString = '.';
String myString1;
String myString2 = '2';
String LSFormat;  

Map<String, Lead> LeadMap = new Map<String, Lead>();

Map<String , id> LSRmap= new  Map<String , id>();


System.debug( '<< LSR - Number of records in this trigger call: ' + Trigger.new.size() );
              
{  
    for( Lead record : Trigger.new )  
    {

    IF (  record.leadsource != Null  )
    {
    myString1 = record.leadsource;

   IF (! myString1.contains(DotString))
   LeadMap.put( record.LeadSource, record );  
   
    IF (  record.leadsource != Null && record.leadsource.contains ('2')  )
    {
    Integer IndexS =  myString1.indexOf(myString2, 0);
    LSFormat = myString1.substring (IndexS );
    LeadMap.put( LSFormat, record ); 
    }
    }
    }
  for(Lead_Source_Reference__c  thisLSR : [select Cookie_Identifier__c, id from Lead_Source_Reference__c where Cookie_Identifier__c in :LeadMap.keySet()])
{
    LSRMap.put(thisLSR.Cookie_Identifier__c,thisLSR.id);
    System.debug( '<<LSRMap ' + LSRMap.size() );
    System.debug( '<<LSRMap ' + LSRMap );
}

for(lead MyLead: Trigger.new){

  if (LSRmap.size() > 0  ) 
System.debug( '<<MyLead' + MyLead);
System.debug( '<<MyLead LeadSource' + MyLead.leadsource);
if (MyLead.leadsource != Null )
{
if (LSRmap.containskey (myString1) || LSRmap.containskey (LSFormat))

{
                      
                      IF (! MyLead.leadsource.contains(DotString))
                       {
                       MyLead.Lead_Source_Reference__c =  LSRmap.get(MyLead.leadsource);
                       }
                       

                       IF ( MyLead.leadsource.contains ('2') && MyLead.leadsource.contains(DotString) )
                       {
                         Integer IndexA =  MyLead.leadsource.indexOf('2', 0);
                        String LSFormatB = MyLead.leadsource.substring (IndexA );
                       MyLead.Lead_Source_Reference__c =  LSRmap.get(LSFormatB); 
                       }
               
               }
         
           }
           }
           }
           }

In several projects, in several orgs, I've scheduled some Batch Apex jobs to run nightly to process large numbers of records. I've run into a couple of problems that are leaving me very uncertain about whether Batch Apex really can handle large jobs.

Every now and then, a job will fail with this error: Unable to write to any of the ACS stores in the alloted time. I first encountered this in September 2010. I filed a Case and created a discussion group posting (http://boards.developerforce.com/t5/Apex-Code-Development/Unable-to-write-to-any-of-the-ACS-stores-in-the-alloted-time/m-p/205908#M36022). After a few weeks, I was finally told that it was an internal issue that had been resolved. After months of running nightly Batch Apex jobs without this problem, it just recurred.

A second issue is that, every now and then, a Batch Apex job gets stuck in the queue in the "Queued" state. When you launch a Batch Apex job, it gets added to the queue in the "Queued" state, and when the system gets around to executing it, the job gets moved to a "Processing" state. Well, I have batch jobs that have been stuck in the "Queued" state since early January. I've had cases open on this problem for over a month, and while the Case finally found its way to Tier 3 Support, there's still no sign of a resolution.

In both cases, the issue is NOT an Apex coding problem. It's an issue with how the platform is queueing and processing Batch Apex jobs.

I'm wondeirng whether anybody else has run into these problems, or other problems executing Batch Apex jobs. What problems have you run into? How have you resolved or worked around them?

Thanks for your insights.

 
  • February 04, 2011
  • Like
  • 0

Hi,

 

we have a requirement where we need to show Logged In User's calendar on a VF Tab(with activities on it).I tried with  CalendarSimple code share sample and on the VF page added a tag "<apex:stylesheet value="/sCSS/Theme/common.css " />" .But its only gave me a proper background but non of the functions are working on the page.(say - addEvent) and its showing some task on the calendar those are nowhere related to logged in user.

If any one can help that would be great.

 

 

Thanking you

Tonnistha

tonnisthasonia@gmail.com

OK, so here is my first time asking for help here - below is a trigger on lead, it should query a custom object, and if a match is found, update a lookup field on the lead with the custom object id - Works 100% in Sandbox, fails in production(does not populate all leads in a batch with matching custom object IDs, only about 70%)! Any recommendations?

Thanks!

 

 

trigger LeadSourceRef on Lead( before insert ) {

String DotString = '.';
String myString1;
String myString2 = '2';
String LSFormat;  

Map<String, Lead> LeadMap = new Map<String, Lead>();

Map<String , id> LSRmap= new  Map<String , id>();


System.debug( '<< LSR - Number of records in this trigger call: ' + Trigger.new.size() );
              
{  
    for( Lead record : Trigger.new )  
    {

    IF (  record.leadsource != Null  )
    {
    myString1 = record.leadsource;

   IF (! myString1.contains(DotString))
   LeadMap.put( record.LeadSource, record );  
   
    IF (  record.leadsource != Null && record.leadsource.contains ('2')  )
    {
    Integer IndexS =  myString1.indexOf(myString2, 0);
    LSFormat = myString1.substring (IndexS );
    LeadMap.put( LSFormat, record ); 
    }
    }
    }
  for(Lead_Source_Reference__c  thisLSR : [select Cookie_Identifier__c, id from Lead_Source_Reference__c where Cookie_Identifier__c in :LeadMap.keySet()])
{
    LSRMap.put(thisLSR.Cookie_Identifier__c,thisLSR.id);
    System.debug( '<<LSRMap ' + LSRMap.size() );
    System.debug( '<<LSRMap ' + LSRMap );
}

for(lead MyLead: Trigger.new){

  if (LSRmap.size() > 0  ) 
System.debug( '<<MyLead' + MyLead);
System.debug( '<<MyLead LeadSource' + MyLead.leadsource);
if (MyLead.leadsource != Null )
{
if (LSRmap.containskey (myString1) || LSRmap.containskey (LSFormat))

{
                      
                      IF (! MyLead.leadsource.contains(DotString))
                       {
                       MyLead.Lead_Source_Reference__c =  LSRmap.get(MyLead.leadsource);
                       }
                       

                       IF ( MyLead.leadsource.contains ('2') && MyLead.leadsource.contains(DotString) )
                       {
                         Integer IndexA =  MyLead.leadsource.indexOf('2', 0);
                        String LSFormatB = MyLead.leadsource.substring (IndexA );
                       MyLead.Lead_Source_Reference__c =  LSRmap.get(LSFormatB); 
                       }
               
               }
         
           }
           }
           }
           }
I'm curious if anyone has any crafty ways to style text in a dataTable based on the values of the data in the table. For example if I have a dataTable of Opportunity
information I would like to highlight all rows where the opp amount is greater than 25000.

My first thought was that if it's logical I should try to control it in the controller so I tried is passing strings of css to the page. It works but I have no way of analyzing the data to see what style I should return.

Code:
This works but there is no logic and it makes everything red.

Page: <apex:dataTable value="{!opportunities}" var="opp" styleClass="list" id="table"> <apex:column> <apex:facet name="header"><b>Amount</b></apex:facet> <apex:outputText value="{!opp.amount}" style="{!style}"/> </apex:column> Controller: public String getStyle() { return 'color: red'; }

With this small success I then tried to pass data from the page to the controller so the controller could evaluate the data and then return the correct styling
but this is where things start to break down. It would appear getter methods can not take arguments and I think I read this somewhere as well.

Code:
PAGE:

<apex:dataTable value="{!opportunities}" var="opp" styleClass="list" id="table">
<apex:column>
<apex:facet name="header">Owner</apex:facet>
<apex:outputText value="{!opp.amount}" style="{!style(opp)}"/>
</apex:column>

public String getStyle(Opportunity opp){
string style;
if(opp.amount > 25000){
style = 'color:red';
}else{
style = 'color:black';
}
return style;
}

Does anyone have any other ideas on how I could achieve this type of behavior?

Thanks,
Jason



Message Edited by TehNrd on 05-12-2008 09:36 AM