• Marc Friedman
  • NEWBIE
  • 25 Points
  • Member since 2007

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

Currently we have account managers who call our customers and collect certain information over the phone. 

 

I would like to be able to send a link to a customer via email that would take them to a form on our public site where they can complete a form and that data would then be associated with an account record in salesforce.com.

 

is that possible?

 

Thanks

CR

 

 

We're receiving an error stating that we have too many query rows, but the debug log is not showing us where these are coming from. Below is each line in the debug log, in order, containing "SOQL_EXECUTE_END" and its corresponding SQL statement:

11:05:55.603 (1603125374)|SOQL_EXECUTE_BEGIN|[27]|Aggregations:0|select AccountId, SUM(Amount) total from Opportunity where (IsWon = true and Rollup_Stop_Date__c > :tmpVar1 and AccountId = :tmpVar2) group by AccountId
11:05:58.148 (4148435199)|SOQL_EXECUTE_END|[27]|Rows:292
11:05:58.149 (4149429111)|SOQL_EXECUTE_BEGIN|[30]|Aggregations:0|select Id, ParentId, TTM_Sales__c from Account where Id = :tmpVar1
11:05:58.185 (4185336466)|SOQL_EXECUTE_END|[30]|Rows:293
...
11:06:00.810 (6810750395)|SOQL_EXECUTE_BEGIN|[18]|Aggregations:0|select Id, AccountId, Account_Level_Expire__c, Account_Level__c, Hierarchy_TTM_Sales__c, CompanyName from User where AccountId IN :tmpVar1
11:06:00.906 (6906647173)|SOQL_EXECUTE_END|[18]|Rows:365
...
11:06:03.387 (9387092122)|SOQL_EXECUTE_BEGIN|[114]|Aggregations:0|select ParentId, SUM(TTM_Sales__c) total from Account where ParentId = :tmpVar1 group by ParentId
11:06:03.412 (9412617167)|SOQL_EXECUTE_END|[114]|Rows:14
11:06:03.412 (9412951386)|SOQL_EXECUTE_BEGIN|[117]|Aggregations:0|select Id, Hierarchy_TTM_Sales__c, ParentId, TTM_Sales__c from Account where Id = :tmpVar1
11:06:03.447 (9447288861)|SOQL_EXECUTE_END|[117]|Rows:301
11:06:03.489 (9489047107)|SOQL_EXECUTE_BEGIN|[151]|Aggregations:0|select Id, ParentId, TTM_Sales__c from Account
11:06:03.509 (9509692382)|SOQL_EXECUTE_END|[151]|Rows:140
...
Number of query rows: 30222 out of 50000 ******* CLOSE TO LIMIT

So, this is showing that it selecting a total of 1405 rows, then all of the sudden it is at 30222 without ever having shown that it selected anywhere near this many records. Thoughts?

Thanks,
Marc

Hi,

 

We have several Users creating Cases using Salesforce for Outlook. We'd like the Cases hadnled differently depending on who created the Case. However, all Cases are created using the Automated Case User. Other than creating a separate Email2Case address for each User (which is not scalable, since they each already need 10), is there any way to get Salesforce to determine which User created the Case from Salesforce for Outlook?

 

Thanks,

Marc

We are using the Data Loader 25.0.1 to import Users from a CSV file. We have confirmed that each row in the CSV has its own unique email address corresponding to the unique User. We have also confirmed that the SDL file is properly mapped. When we import the records, the Data Loader is picking one of the email addresses and duplicating it for all of the Users. Example:

 

IMPORT FILE:

Pat Anderson, panderson@none.com

Jamie Kobayashi, jkobayashi@none.com

Sam Valdez, svaldez@none.com

 

IMPORTED USER RECORDS IN SALESFORCE

Pat Anderson, panderson@none.com

Jamie Kobayashi, panderson@none.com

Sam Valdez, panderson@none.com

 

The issue of course is that once these Users have been loaded, we have to manually change the email address (we have tried with the Data Loader but this does not work) so that the Users can receive the login email to log into the system. We have thousands of Users, so manually changing email addresses is not a viable option.

 

Has anyone else seen this behavior, or has suggestions for possible causes/cures?

 

Thanks,

Marc

Hi,

 

We have a Scheduler Class for a Batch Class, both of which are working fine as evidenced by the fact that they have both successfully fired on schedule the last three days.  The Test Class, however, seems to be written incorrectly / not invoking properly.  The text class is below:

 

@isTest

class TestStampForecastLastUpdated {
	
	static testMethod void testStampForecastLastUpdated() {
		
		// Declare Local Variables
		final string							accountRecordType = 'Distributor';
		Id										accountRecordTypeId;
		Map<String, Schema.RecordTypeInfo>		accountRecordTypes = new Map<String, Schema.RecordTypeInfo>();
		CronTrigger								cronTrigger;
		String 									jobId;
		final Date								monthEnd = date.valueOf('2008-02-29 00:00:00');
		final Date								today = System.today();
		Product2								product;
		
		// Get Account Record Type Ids
		accountRecordTypes = Schema.SObjectType.Account.getRecordTypeInfosByName();
		accountRecordTypeId = accountRecordTypes.get(accountRecordType).getRecordTypeId();

		// Create an Account
		Account a1 = new Account (Name = 'Acme', Product_Discount_Amount__c = 9, RecordTypeId = accountRecordTypeId);
		Insert a1;
		
		// Get a Product
		product = [SELECT Id FROM Product2 WHERE IsActive = true AND Forecast__c = true LIMIT 1];
		
		// Create a Forecast record in the past and one in the future
		Forecast__c f1 = new Forecast__c (Account__c = a1.id, Backlog_Quantity__c = 1, Backlog_Amount__c = 100, Est_Forecast_Rev__c = 100, Last_Updated__c = date.valueOf('2008-02-15 00:00:00'), Month_End_Date__c = monthEnd, Product__c = product.Id, Quantity__c = 1, Shipped__c = 1, Shipped_Amount__c = 100, Shipped_and_Backlog__c = 150);
		Forecast__c f2 = new Forecast__c (Account__c = a1.id, Backlog_Quantity__c = 1, Backlog_Amount__c = 100, Est_Forecast_Rev__c = 100, Last_Updated__c = date.valueOf('2008-02-15 00:00:00'), Month_End_Date__c = today, Product__c = product.Id, Quantity__c = 1, Shipped__c = 1, Shipped_Amount__c = 100, Shipped_and_Backlog__c = 150);
		insert f1;
		insert f2;
		
		// Execute the batchable test
		Test.startTest();

		// Schedule the test job
		String scheduleExpression = '0 0 0 3 9 ? 2022';
		jobId = System.schedule('testScheduleStampForecastLastUpdated', scheduleExpression, new ScheduleStampForecastLastUpdated());
		
		// Get the CronTrigger info
		cronTrigger = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE Id = :jobId];
		
		// Assert that the expressions are the same
		System.assertEquals(scheduleExpression, cronTrigger.CronExpression);
		
		// Assert that the Cron job has not started
		System.assertEquals(cronTrigger.TimesTriggered, 0);
		
		// Assert that the Forecasts have their original values
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f1.Id].Last_Updated__c, date.valueOf('2008-02-15 00:00:00'));
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f2.Id].Last_Updated__c, date.valueOf('2008-02-15 00:00:00'));
		
		// Stop the test
		Test.stopTest();
		
		// Assert that the Forecasts have their proper values
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f1.Id].Last_Updated__c, date.valueOf('2008-02-15 00:00:00'));
System.debug('f2 = ' + [SELECT Status__c FROM Forecast__c WHERE Id = :f2.Id]);
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f2.Id].Last_Updated__c, System.today());
	}
}

 

The last assertion fails, although the System.debug line shows that it should have been processed.  Again, the Scheduler and Batch are working properly, which leads me to believe that this Test Class is constructed improperly.

 

Relevant code from the Scheduler and Batch below, although again, they have fired properly as scheduled every day since scheduled.

 

global class ScheduleStampForecastLastUpdated implements Schedulable {

	global void execute (SchedulableContext sc) {

		stampForecastLastUpdated sflu = new stampForecastLastUpdated('SELECT Last_Updated__c FROM Forecast__c WHERE Status__c = \'Active\'');
		database.executebatch(sflu);
	}
}

 

global class StampForecastLastUpdated implements Database.Batchable<sObject>{

	global final string	query;
	date				today = date.today();

	global StampForecastLastUpdated(String query) {
		this.query = query;
	}
	
	global Database.QueryLocator start(Database.BatchableContext BC) {
		return Database.getQueryLocator(query);
	}

	global void execute(Database.BatchableContext BC, List<sObject> scope) {
		List<Forecast__c> forecasts = new List<Forecast__c>();

		for (sObject s : scope) {
			Forecast__c f = (Forecast__c)s;
			f.Last_Updated__c = today;
			forecasts.add(f);
		}
		update forecasts;
	}

	global void finish(Database.BatchableContext BC) {
	}
}

 

 

Thanks,

Marc

Hello,

 

We are seeing odd behavior with business hours in Apex. We are setting Milestone dates for a Project by starting with the Live Date (the final Milestone), and working backwards through the list of Milestones – each of which has a “days since previous Milestone”.  

 

This is the relevant portion of the block of code:

milliseconds = milestoneMap.get(j).Days_Since_Previous_Milestone__c.longValue() * 86400000L * -1;

 

System.debug('XXXXXX About to subtract ' + milliseconds + ' from ' + milestoneDateTime + ' for ' + projectMilestone.Milestone__c);

 

newMidDay = BusinessHours.add(bh.Id, milestoneDateTime, milliseconds);

 

System.debug('XXXXXX The number of milliseconds subtracted was ' + BusinessHours.diff(bh.id, newMidDay, milestoneDateTime)); 

 

When we run the Debug Log, it reads “XXXXXX About to subtract -172800000 from 2010-06-22 00:00:00 for a09R0000005dlMSIAY”, which is correct, because the next Milestone is two business days earlier, and there are 172800000 milliseconds in two days (it does read that it’s going to “subtract” a negative number, but you can see how the code is actually adding the negative number).  Now, the next debug entry, which is after only one line of code (the BusinessHours.add) states “XXXXXX The number of milliseconds subtracted was 86400000”.  How could this be?  So, it’s saying “I’m about to subtract 172800000 milliseconds, but I actually subtracted 86400000.”

 

Our only Business Hours record has 24 hours Mon - Fri and zero hours on Sat and Sun (I've confirmed through Apex Explorer).  No holidays.  The above example is subtracting two days from Monday and arriving at Friday (when it should arrive at Thursday, and should also not contradict itself with stating it's going to subtract one number but actually subtracting another).  This is also odd, because if it was "ignoring" business hours completely, it would have subtracted two days from Monday and arrived at Sunday.  Yet, if it subtracts two days from a Thursday, it accurately arrives at Tuesday (the debug log states “I’m about to subtract 172800000 milliseconds, and I did subtract 172800000.”

 

Thoughts?

 

Thanks,

Marc

Hi All,
 
The following code works fine, but I was wondering if anyone had any suggestions about ways it can be optimized.
 
Relevant objects / relationships:
  • Employer_Subgroup__c is a child object of Accounts
  • Reward_Activity__c is a standalone object
  • Employer_Group_Reward_Activity__c is a child of Accounts with a Lookup to Reward_Activity__c
  • Employer_Subgroup_Reward_Activity__c is a standalone object with Lookups to Employer_Subgroup__c and Reward_Activity__c

Thanks,

Marc

Code:

global class PopulateSubgroups {

 WebService static Integer populateSubgroups(List<String> args, String groupId) {
  
  // Set the return variable to -1 in case the functional fails
  Integer result = -1;
  
  //Get a list of all Subgroups for the Group
  Employer_Subgroup__c[] subgroups = [select id from Employer_Subgroup__c where Group_Name__c = :groupId];
  
  // Return 0 if there are no Subgroups for the Group
  if (subgroups.size() == 0) {
   result = 0;
  
  } else {
   result = 1;
   
   // Create the array of Employer Subgroup Reward Activities to upsert
   Employer_Subgroup_Reward_Activity__c[] esras = new Employer_Subgroup_Reward_Activity__c[]{};
   
   // Get the Reward Amount and Reward Activity IDs for the selected Employer Group Reward Activities
   Employer_Group_Reward_Activity__c[] egras = [select Amount__c, Reward_Activity__c from Employer_Group_Reward_Activity__c where id in :args];
   
   // Loop through each Employer Group Reward Activity to see if it is already associated with any of the Subgroups
   for (Integer i = 0; i < egras.size(); i++) {
    
    // Loop through each Subgroup
    for (Integer j = 0; j < subgroups.size(); j++) {
     Integer k = [select count() from Employer_Subgroup_Reward_Activity__c where Reward_Activity__c = :egras[i].Reward_Activity__c and Employer_Subgroup__c = :subgroups[j].id];
     
     // If the same association exists more than once, ask User to notify the administrator (there is code to prevent this from happening, but is a good check just in case)
     if (k > 1) {
      result = -2;
     
     // If the association exists, populate the Employer Subgroup Reward Activity record and update the Amount
     } else if (k == 1) {
      Employer_Subgroup_Reward_Activity__c esra = [select id from Employer_Subgroup_Reward_Activity__c where Reward_Activity__c = :egras[i].Reward_Activity__c and Employer_Subgroup__c = :subgroups[j].id];
      esra.Amount__c = egras[i].Amount__c;
      esras.add(esra);
     
     // If the association doesn't exist, create it
     } else if (k == 0) {
      Employer_Subgroup_Reward_Activity__c esra = new Employer_Subgroup_Reward_Activity__c();
      esra.Reward_Activity__c = egras[i].Reward_Activity__c;
      esra.Employer_Subgroup__c = subgroups[j].id;
      esra.Amount__c = egras[i].Amount__c;
      esras.add(esra);
     }
     // End If...else if...
    }
   }
   // Upsert the Employer Subgroup Reward Activities
   try {
    upsert esras;
   } catch (System.DmlException e) {
    System.debug(e.getMessage());
    result = -1;
   }
  }
  
  return(result);
 }
}


 

We are using the Data Loader 25.0.1 to import Users from a CSV file. We have confirmed that each row in the CSV has its own unique email address corresponding to the unique User. We have also confirmed that the SDL file is properly mapped. When we import the records, the Data Loader is picking one of the email addresses and duplicating it for all of the Users. Example:

 

IMPORT FILE:

Pat Anderson, panderson@none.com

Jamie Kobayashi, jkobayashi@none.com

Sam Valdez, svaldez@none.com

 

IMPORTED USER RECORDS IN SALESFORCE

Pat Anderson, panderson@none.com

Jamie Kobayashi, panderson@none.com

Sam Valdez, panderson@none.com

 

The issue of course is that once these Users have been loaded, we have to manually change the email address (we have tried with the Data Loader but this does not work) so that the Users can receive the login email to log into the system. We have thousands of Users, so manually changing email addresses is not a viable option.

 

Has anyone else seen this behavior, or has suggestions for possible causes/cures?

 

Thanks,

Marc

Currently we have account managers who call our customers and collect certain information over the phone. 

 

I would like to be able to send a link to a customer via email that would take them to a form on our public site where they can complete a form and that data would then be associated with an account record in salesforce.com.

 

is that possible?

 

Thanks

CR

 

 

Hi,

 

We have a Scheduler Class for a Batch Class, both of which are working fine as evidenced by the fact that they have both successfully fired on schedule the last three days.  The Test Class, however, seems to be written incorrectly / not invoking properly.  The text class is below:

 

@isTest

class TestStampForecastLastUpdated {
	
	static testMethod void testStampForecastLastUpdated() {
		
		// Declare Local Variables
		final string							accountRecordType = 'Distributor';
		Id										accountRecordTypeId;
		Map<String, Schema.RecordTypeInfo>		accountRecordTypes = new Map<String, Schema.RecordTypeInfo>();
		CronTrigger								cronTrigger;
		String 									jobId;
		final Date								monthEnd = date.valueOf('2008-02-29 00:00:00');
		final Date								today = System.today();
		Product2								product;
		
		// Get Account Record Type Ids
		accountRecordTypes = Schema.SObjectType.Account.getRecordTypeInfosByName();
		accountRecordTypeId = accountRecordTypes.get(accountRecordType).getRecordTypeId();

		// Create an Account
		Account a1 = new Account (Name = 'Acme', Product_Discount_Amount__c = 9, RecordTypeId = accountRecordTypeId);
		Insert a1;
		
		// Get a Product
		product = [SELECT Id FROM Product2 WHERE IsActive = true AND Forecast__c = true LIMIT 1];
		
		// Create a Forecast record in the past and one in the future
		Forecast__c f1 = new Forecast__c (Account__c = a1.id, Backlog_Quantity__c = 1, Backlog_Amount__c = 100, Est_Forecast_Rev__c = 100, Last_Updated__c = date.valueOf('2008-02-15 00:00:00'), Month_End_Date__c = monthEnd, Product__c = product.Id, Quantity__c = 1, Shipped__c = 1, Shipped_Amount__c = 100, Shipped_and_Backlog__c = 150);
		Forecast__c f2 = new Forecast__c (Account__c = a1.id, Backlog_Quantity__c = 1, Backlog_Amount__c = 100, Est_Forecast_Rev__c = 100, Last_Updated__c = date.valueOf('2008-02-15 00:00:00'), Month_End_Date__c = today, Product__c = product.Id, Quantity__c = 1, Shipped__c = 1, Shipped_Amount__c = 100, Shipped_and_Backlog__c = 150);
		insert f1;
		insert f2;
		
		// Execute the batchable test
		Test.startTest();

		// Schedule the test job
		String scheduleExpression = '0 0 0 3 9 ? 2022';
		jobId = System.schedule('testScheduleStampForecastLastUpdated', scheduleExpression, new ScheduleStampForecastLastUpdated());
		
		// Get the CronTrigger info
		cronTrigger = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE Id = :jobId];
		
		// Assert that the expressions are the same
		System.assertEquals(scheduleExpression, cronTrigger.CronExpression);
		
		// Assert that the Cron job has not started
		System.assertEquals(cronTrigger.TimesTriggered, 0);
		
		// Assert that the Forecasts have their original values
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f1.Id].Last_Updated__c, date.valueOf('2008-02-15 00:00:00'));
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f2.Id].Last_Updated__c, date.valueOf('2008-02-15 00:00:00'));
		
		// Stop the test
		Test.stopTest();
		
		// Assert that the Forecasts have their proper values
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f1.Id].Last_Updated__c, date.valueOf('2008-02-15 00:00:00'));
System.debug('f2 = ' + [SELECT Status__c FROM Forecast__c WHERE Id = :f2.Id]);
		System.assertEquals([SELECT Last_Updated__c FROM Forecast__c WHERE Id = :f2.Id].Last_Updated__c, System.today());
	}
}

 

The last assertion fails, although the System.debug line shows that it should have been processed.  Again, the Scheduler and Batch are working properly, which leads me to believe that this Test Class is constructed improperly.

 

Relevant code from the Scheduler and Batch below, although again, they have fired properly as scheduled every day since scheduled.

 

global class ScheduleStampForecastLastUpdated implements Schedulable {

	global void execute (SchedulableContext sc) {

		stampForecastLastUpdated sflu = new stampForecastLastUpdated('SELECT Last_Updated__c FROM Forecast__c WHERE Status__c = \'Active\'');
		database.executebatch(sflu);
	}
}

 

global class StampForecastLastUpdated implements Database.Batchable<sObject>{

	global final string	query;
	date				today = date.today();

	global StampForecastLastUpdated(String query) {
		this.query = query;
	}
	
	global Database.QueryLocator start(Database.BatchableContext BC) {
		return Database.getQueryLocator(query);
	}

	global void execute(Database.BatchableContext BC, List<sObject> scope) {
		List<Forecast__c> forecasts = new List<Forecast__c>();

		for (sObject s : scope) {
			Forecast__c f = (Forecast__c)s;
			f.Last_Updated__c = today;
			forecasts.add(f);
		}
		update forecasts;
	}

	global void finish(Database.BatchableContext BC) {
	}
}

 

 

Thanks,

Marc