• Joe2theSon
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

I've been looking through exisiting issues with gonernors limit and I am puzzled at how I can change my current trigger on lead.

 

My custom made checkDups lead checks to see if Lead exists based on incoming leads email address. If count is not 0, it marks the incoming leads' status with Open - Duplicate.

 

Find below the code that is causing "Too many SOQL queries: 12" error

 

trigger CheckDups on Lead (before insert, after insert) {    List<DocDownload__c> toAdd = new List<DocDownload__c>();    if (Trigger.isBefore) {        for (Lead newLead:Trigger.new) {            Integer dupCnt=[Select count( ) from Lead where email=:newLead.email];            if (dupCnt > 0) {                newLead.Status = 'Open - Duplicate';            }            }    }        if (Trigger.isAfter) {        String displayDate = '';        for (Lead newAfterLead:Trigger.new) {            if (newAfterLead.LeadType__c == 'DOWNLOAD') {                Datetime myDate = System.now();                displayDate = myDate.format('MM-dd-yyyy hh:mm aaa z');                toAdd.add(new DocDownload__c(DocID__c=newAfterLead.DocID__c,DocTitle__c=newAfterLead.DocTitle__c,Email__c=newAfterLead.Email, DownloadDateTime__c=myDate, Title__c=newAfterLead.Title, Company__c=newAfterLead.Company, DisplayDate__c=displayDate, IsManual__c=false));             }        }                insert toAdd;    } 

} 

 

What I'm puzzled about is this.

1. Is trigger wating until more than 20 records are collected before firing? This doesn't to be the case cuz every new lead that comes in from our website, it gets processed right away. The for loop that i have under before insert can not exceed 20 calls unless the trigger waits until more then 20 leads are collected.

 

2. How can i run bulk process for this? I need to check to see if each new lead has existing value in the system. Wouldn't i need to run for loop? 

Hello everyone. I'm stuck at an issue where I THINK i know what's going on but need clarification and guide to solution.

 

I have a trigger and WebService set up on salesforce which.

The Trigger is doing the following.

When ever new Web-to-lead comes in, it checks to see if the lead email already exists as well as if it is document download. If it's document download, it inserts new record into a custom object with following information:

 

  • DocID:Double
  • DOcTitle:Text
  • Download Date: DateTIme
  • DisplayDate: text 

 

The trigger will convert the System.now() into string using format (MM/dd/yyyy HH:MM:sss)

 

The WebService basically inserts new downloads from our website with same information.

 

Here is the issue.

 

When records are added through WebService, the datetime conversion to string automatically uses WebService login's timezone and correctly displays the time.

 

HOWEVER, trigger is simply converting System.now() to String values which comes out as formatted UTC time value.  

 

My theory is that trigger doesn't have user time zone set and thus doesn't know what to do.

 

Is there work around for allowing triggers to also convert time based on webservice login? 

Hi everyone, I'm very new to SalesForce and would like to get some assistance.
Our company has web-to-case/lead setup where on submit of the form, .NET code submits the form via http request to salesforce.com/servlet/servlet.Webtocase.
 
It than returns the user to thank you page. We can notice through email with case ID.
 
What i like to do is, on top of that email being sent out, i'd like for my website to recieve the response from salesforce so that i can do further processing such as getting the case/lead number, query details regarding the case/lead, search for existing case/leads based on email address and so on.
 
Thank you for your help in advance.

I've been looking through exisiting issues with gonernors limit and I am puzzled at how I can change my current trigger on lead.

 

My custom made checkDups lead checks to see if Lead exists based on incoming leads email address. If count is not 0, it marks the incoming leads' status with Open - Duplicate.

 

Find below the code that is causing "Too many SOQL queries: 12" error

 

trigger CheckDups on Lead (before insert, after insert) {    List<DocDownload__c> toAdd = new List<DocDownload__c>();    if (Trigger.isBefore) {        for (Lead newLead:Trigger.new) {            Integer dupCnt=[Select count( ) from Lead where email=:newLead.email];            if (dupCnt > 0) {                newLead.Status = 'Open - Duplicate';            }            }    }        if (Trigger.isAfter) {        String displayDate = '';        for (Lead newAfterLead:Trigger.new) {            if (newAfterLead.LeadType__c == 'DOWNLOAD') {                Datetime myDate = System.now();                displayDate = myDate.format('MM-dd-yyyy hh:mm aaa z');                toAdd.add(new DocDownload__c(DocID__c=newAfterLead.DocID__c,DocTitle__c=newAfterLead.DocTitle__c,Email__c=newAfterLead.Email, DownloadDateTime__c=myDate, Title__c=newAfterLead.Title, Company__c=newAfterLead.Company, DisplayDate__c=displayDate, IsManual__c=false));             }        }                insert toAdd;    } 

} 

 

What I'm puzzled about is this.

1. Is trigger wating until more than 20 records are collected before firing? This doesn't to be the case cuz every new lead that comes in from our website, it gets processed right away. The for loop that i have under before insert can not exceed 20 calls unless the trigger waits until more then 20 leads are collected.

 

2. How can i run bulk process for this? I need to check to see if each new lead has existing value in the system. Wouldn't i need to run for loop? 

Hi,

I need to write a piece of code which will get the List of Opportunity difrentiated by some criteria and want to email those records every weekends.

Its like Time Based coading.

I have read about time dependent Workflow triggers but it doesnt resolves my problem because it does not provide flexibility to write the Apex code.

I want to run the code once in every week.

Can anyone give some suggestions?

Thanks in Advance!