• davescar
  • NEWBIE
  • 25 Points
  • Member since 2010

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

Hi All,

 

Cannot figure out why this would be causing the classic "Too many SQL Queries" error. As far as I know I have implemented what is  best-practice for bulk processing.

 

However when insert tasks using data loader, it's generating the error above.

 

Any help pointers appreciated - thanks

 

 

trigger CloseOriginalTask on Task (after insert) {

	List<Task> taskRecords = [select TaskIdFollowedUp__c from Task where Id IN:Trigger.newMap.keySet()];
	List<Task> tasksForUpdate = new List<Task>{};
	
	if (taskRecords.size()!=0){
	
	for (Task taskRecord : taskRecords){
		
		Id taskId = taskRecord.TaskIdFollowedUp__c;
		List<Task> originalTask = [select Id, Status from Task where Id=:taskId];
		
			for (Task t:originalTask){
					t.Status = 'Completed';	
					tasksForUpdate.add(t);	
			}
		
			
	}
		
	
	update tasksForUpdate;
	
	}

}

 

 

Hi,

 

I have  a javascript list button "Create Purchase order" on custom object Order_Lines__c(child object of Sales_Order__c) which creates a purchase order for the selected order lines.

The code goes like this :

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}


var records = {!GETRECORDIDS($ObjectType.Order_Line__c)};
var newRecords = [];

/*Ensure atleast one order line is selected*/

if (records[0] == null)
{
alert("Please select at least one Order Line")
}

/*Create a purchase order for the selected records*/
else
{
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Order_line__c");
c.id = records[n];
newRecords.push(c);
}
result = sforce.connection.update(newRecords);
/*Open a new Purchase Order form and prepopulate with values*/

window.location.href ="/a0I/e?retURL=%2Fa0I%2Fo"+
"&CF00NR0000000cvG6={!Sales_Order__c.Name}"+
"&CF00NR0000000cvEt={!Sales_Order__c.Default_Warehouse__c}" +
"&00NR0000000cvEU={!Sales_Order__c.Order_Date__c}
}

This is working fine.
Now i want to add another validation:The field supplier__c on the order lines object must have the same value for the selected records.


I have tried adding the validation as follows:

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var records = {!GETRECORDIDS($ObjectType.Order_Line__c)};
var newRecords = [];
/*Check if records are selected*/
if (records[0] == null)
{
alert("Please select at least one Order Line");
}


 else{
          var myarray=new Array();
          for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Order_line__c");
c.id = records[n];
/*Copy the supplier field into an array for all the selected order lines*/
myarray[n]=c.supplier__c;
              }                                                             }
var t=array.length-1;
for (var d=0;d<t;d++)
{
if(array[d] <>array[d+1]){
alert("SOrry ,need same supplier for each order line");

}

else
{
/*Code for creating a new Purchase order*/
}
}

however this is not working and it gives a syntax error.

 

Please help with the syntax and the logic used  if its not ok.

Hi All,

 

Cannot figure out why this would be causing the classic "Too many SQL Queries" error. As far as I know I have implemented what is  best-practice for bulk processing.

 

However when insert tasks using data loader, it's generating the error above.

 

Any help pointers appreciated - thanks

 

 

trigger CloseOriginalTask on Task (after insert) {

	List<Task> taskRecords = [select TaskIdFollowedUp__c from Task where Id IN:Trigger.newMap.keySet()];
	List<Task> tasksForUpdate = new List<Task>{};
	
	if (taskRecords.size()!=0){
	
	for (Task taskRecord : taskRecords){
		
		Id taskId = taskRecord.TaskIdFollowedUp__c;
		List<Task> originalTask = [select Id, Status from Task where Id=:taskId];
		
			for (Task t:originalTask){
					t.Status = 'Completed';	
					tasksForUpdate.add(t);	
			}
		
			
	}
		
	
	update tasksForUpdate;
	
	}

}

 

 

Hi everyone,

 

I need to generate failures in the execution of a batch class in order to cover a significant amount of the batch class code.

Any idea on how I can go about this?

 

 

Thanks in advance,

 

SGM