You need to sign in to do that
Don't have an account?
Update failed. First exception on row 0 with id 00T9000000Qj3DlEAJ; first error: ENTITY_IS_DELETED
HI
i wriiten one schedular class am getting this error after some days
its worked for me some days
but after its showing this error
System.DmlException: Update failed. First exception on row 0 with id 00T9000000Qj3DlEAJ; first error: ENTITY_IS_DELETED, entity is deleted: []
this is my class.
// **** schedular class for task escaltion
global with sharing class Task_Escalation implements Schedulable {
public List<Client_Requirement__c> clientreq=new list<Client_Requirement__c>();
public List<Client_Requirement__c> clientreq1=new list<Client_Requirement__c>();
public List<Client_Requirement__c> clientreq2=new list<Client_Requirement__c>();
public list<task> listtask=new List<task>();
public list<task> listtask2=new List<task>();
public list<task> listtask3=new List<task>();
public list<task> listtask4=new List<task>();
public set<id> listtask1=new set<id>();
public set<id> CRID=new set<id>();
public set<id> sysid=new set<id>();
global void execute(SchedulableContext SC) {
try{
//--------------------------------------------------------------------------------
// list of all client requirements
clientreq=[select id,name,RecordTypeid,Ownerid from Client_Requirement__c];
system.debug('List of client requirement'+clientreq);
for(Client_Requirement__c cr: clientreq)
{
CRID.add(cr.id);// fetching the list of all client req IDS
}
// query for fetching the tasks that are not closed with in 3 days
listtask=[Select t.CreatedDate, t.Id, t.LastModifiedById, t.LastModifiedDate, t.OwnerId, t.Priority,
t.Status, t.Subject, t.WhatId, t.WhoId from Task t where Whatid=:CRID and Status='Not Started' and Created_date__c=today and ActivityDate=null];
system.debug('List of tasks that are not closed with in 3 days '+listtask);
if(listtask.size()>0)
{
for(task t: listtask)
{
if(t.OwnerId=='00590000001qNM7' || t.OwnerId=='00590000001qNMq' || t.OwnerId=='00590000001qNMM' || t.OwnerId=='00590000001qNKQ' || t.OwnerId=='00590000001qNKu' || t.OwnerId=='00590000001qNMR' || t.OwnerId=='00590000001qNL6')
{
t.OwnerId='00590000001qNKB';// Assigning the crm owner to the all the tasks
listtask2.add(t);
}
}
update listtask2; //updating the tasks
system.debug('List of tasks that are updated to user crm head '+listtask2);
}
//-----------------------------------------------------
clientreq2=[select id,name,RecordTypeid,Ownerid from Client_Requirement__c];
system.debug('List of client requirement'+clientreq2);
for(Client_Requirement__c cr: clientreq2)
{
sysid.add(cr.id);// fetching the list of all client req IDS and ownerid='00590000001qNKB'
}
system.debug('list of idssss for system admin'+sysid);
// query for fetching the task that crm head user not completed the tasks
listtask3=[Select t.CreatedDate, t.Id, t.LastModifiedById, t.LastModifiedDate, t.OwnerId, t.Priority,
t.Status, t.Subject, t.WhatId, t.WhoId from Task t where whatid=:sysid and Status='Not Started' and Created_date_after_6_days__c=today and ActivityDate=null];
system.debug('List of tasks that are not closed after 2 days '+listtask3);
if(listtask3.size()>0)
{
for(task t: listtask3)
{
if(t.OwnerId=='00590000001qNKB')
{
t.OwnerId='00590000001WzWy';// Assigning the system admin to the tasks that crm head user not completed
listtask4.add(t);
}
}
update listtask4; // updating the tasks.
system.debug('List of tasks that are updated to user sysadmin head '+listtask4);
}
}catch(Exception e){system.debug('@@@@@@@@@@@@@@'+e);}
}
}
Regards
venkatesh
You've got a lot of hard coded Ids there. You should query the User object and build a <string, Id> map to pull the Id from the name. Alternately, just check the Ids that you are assigning as the owner of the tasks to make sure the exist/are right/don't have any typos, etc. If you're doing this in a sandbox, make sure the User's ID matches between orgs incase one was created before the other org (not a sandbox refresh). Check 00590000001qNKB.
Hi kirkevonphilly,
Thanks for your replay
can please tell me more clearly.
actually this all ids from production only.
I have 5 to 6 user all profile or different
1.east,
2.south,
3.west,
4.north,
5.south1,
6.south2
my requirement is if any one in this 6 created any task,
if they are not completed with in the due date,i need to assign that task to assistant crm,if assistant crm is not completed after 3 days i need to assigen this task to system admin
this is my requirement.
can u please tell me how can i get the users ids.
regards,
venkatesh.
If you go to yourDomain.salesforce.com/00590000001qNKB (where yourDomain is na1, na2, etc), does the User record show?
Through Salesforce.com, go to Setup --> Administer --> Manage Users --> Users and then click on the User you want the ID for. Once you are on that User's record, look at the URL - the User's ID will start with 005.
Programatically, you'd ideally want to do something like this:
Then everywhere you have a hardcoded ID, you can replace the ID with userName2Id.get('the user's last name here');
Of course, you can always ensure that the map contains the user you want to assign, preventing run time errors by using an if (UserName2Id.containsKey('that user's lastname')), throwing an error if it isn't found for some reason (deleted, name change, etc).
You could also do something like this:
Hi thanks for replay
i modified like this this correct or i need change anything
map<Id, User> Id2User = new map<Id, User>([SELECT Id, Name FROM User WHERE Profile.Name IN ('East','Howrah','North and Central','Rajarhat','South I','South II','Newtown')]);
//--------------------------------------------------------------------------------
// list of all client requirements
clientreq=[select id,name,RecordTypeid,Ownerid from Client_Requirement__c];
system.debug('List of client requirement'+clientreq);
for(Client_Requirement__c cr: clientreq)
{
CRID.add(cr.id);// fetching the list of all client req IDS
}
// query for fetching the tasks that are not closed with in 3 days
listtask=[Select t.CreatedDate, t.Id, t.LastModifiedById, t.LastModifiedDate, t.OwnerId, t.Priority,
t.Status, t.Subject, t.WhatId, t.WhoId from Task t where Whatid=:CRID and Status='Not Started' and Created_date__c=today and ActivityDate=null AND OwnerID IN :ID2User.keyset()];
system.debug('List of tasks that are not closed with in 3 days '+listtask);
if(listtask.size()>0)
{
for(task t: listtask)
{
t.OwnerId='00590000001qNKB';// Assigning the crm owner to the all the tasks
listtask2.add(t);
}
update listtask2; //updating the tasks
system.debug('List of tasks that are updated to user crm head '+listtask2);
}
regards
venkatesh.