• BrendaFlynn
  • 0 Points
  • Member since 2010

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 3
I'm interested in identifying and deleting old reports -- anything that hasn't been run in a year, for example. I thought I would be able to do this using a query, but reports and dashboards appear to be meta data and have no tables. Is there some sort of way I can query the meta data about the reports to identify which reports I can delete? Is there any programmatic way to update a batch of reports identified that way?

This is my first week working with Salesforce, coming from a Coldfusion (don't be a hater!) and SQL Server background. 


Our users want to be able to see the number of Contacts for an account at a glance. To accommodate this, we've developed a custom field -- Account.Contact_Count__c which is an integer. Now for the hard part; populating it. We can't do a rollup because you can't roll up child data. So I wrote this bulk updater to do the work. I scheduled it (successfully) in the hopes that would get around the data governance limits, but no such luck.


We have thousands of accounts, and I won't know if they require updating unless I run a query on them. Is there a good way to run this in a background at low demand times? Is there a way that I can run it in blocks of data? Is there some super-duper easy way of running this that I simply didn't know about? Can I have this class call another class in order to reset the count of transactions?  Also, please note that as far as I can tell you can't combine count() with sub queries. I tried to make variations on this query work a number of different ways:


Select a.Contact_Count__C, count(Select ID From Contact Where AccountID = a.ID)

From Account a


I never got it to work. 


I'm currently orders of magnitude away from being able to execute this code. Help me understand that right way to accomplish a task like this in salesforce!


 I've run this both on-demand (so I can see errors) and scheduled. 

global class ModifyContractCount {

//completeRecount updates all records with the latest count of contacts

//the @future makes this available to be scheduled


public static void completeRecount()

{ //Identify the number of contacts for a particular account and update the Contact Count variable appropriately //Create list of records to update.

List<Account> AcctsToUpdate = [ SELECT A.ID, A.Contact_Count__c FROM Account A LIMIT 50 //NOTE: Works with 50 or fewer ];

//Loop through returned records

for(Account a : AcctsToUpdate)


//Identify number of child contacts

Integer NumberOfContacts =

[ SELECT count()FROM Contact WHERE AccountID = :a.Id


//If the Accounts.Contact_Count__c is not the same as the number of child contacts, update the record

if (NumberOfContacts != a.Contact_Count__c)


a.Contact_Count__c = NumberOfContacts; update a; } //end for loop } //end completeRecount method }


//If the Accounts.Contact_Count__c is not the same as the number of child contacts, update the record

if (NumberOfContacts != a.Contact_Count__c)

{a.Contact_Count__c = NumberOfContacts;

update a;}

//end for loop


//end completeRecount method }



Message Edited by BrendaFlynn on 03-05-2010 10:24 AM

The requirement demands that if no lead is created in the last one hour a specified recipient should receive an email saying that no lead was created in the last one hour.



No lead was created within the time period 9:00am to 10:00am. The specified recipient should receive an email.

If no lead is created within the next one hour(10:00am-11:00am) the recipient receives another email.


Now suppose a lead is created at 11:30 am. In this case the specified recipient will not receive an email at 12:00 o'clock. The one hour duration will be counted from 11:30 am. That is if no lead is created till 12:30 pm then the recipient will again receive an email at 12:30 pm.

Please help. 

Hello.  It looks like the value of Origin field in a Web-To-Case is not set until after the case is inserted.  Is that true?  I am writing Before Insert trigger code that should only run for web-to-case, but when I include an if statement for Origin == 'Web', my code doesn't run.  It's only when I comment out the if statement that code runs.


If that is case, is there any other standard way to determine a web-to-case?  Or do I have to create a custom field and link it to a hidden field on the web form?




I am able to add 16000000000 as a value into the Annual Revenue field on account, but if I try and look for accounts with a value greater than that in Apex or the API, I get a


Compile Error: For input string: "16000000000"



account a = [select id, annualrevenue from account where annualrevenue > 16000000000 limit 1][0];




  • March 05, 2010
  • Like
  • 0