You need to sign in to do that
Don't have an account?
renu
Message Edited by renu on 07-09-2008 02:20 PM
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, execution of AfterInsert
I'm trying to write test cases for my APEX code.I searched the Apex documentation and the Apex discussion board but did not find solution. I am getting two errors. I tried but unfortunately not getting the required output. Let me know where i am getting error. I had written the same code in the trigger without using Apex class it was working perfect. But since i need to deploy the trigger i started writing Apex class which gives me these errors.
Thanks in advance for the solution.
This is what i am trying to accomplish.
When ever a new custom object(Client) is created or updated i need to update few fields accordingly.
And the errors are at line 35 and 54
Errrors
1) System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
Trigger.ClientUpdates: line 19, column 1
2) System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
Trigger.ClientUpdates: line 19, column 1
Message Edited by renu on 07-09-2008 02:20 PM
Hello Guys
I am having a similar issue, trying to test a very simple Trigger.
Basically my trigger will kick in when a new contact is inserted, and what it will do is to update the account name associated to the contact.
I created a Class, a Trigger and a TestClass that I am using to test that all works fine:
Class:
Trigger:
Test Class:
But this is the error message I get:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NewContactUpdateOrganizationName: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.UpdateOrganizationNameClass.UpdateOrganizationName: line 8, column 7
Trigger.NewContactUpdateOrganizationName: line 3, column 1
Would you be able to tell me what am I doing wrong?
Thanks
Giorgio
In this case however, Account name should never be null in real life, as it is a Mandatory SF field, so if I entered a contact thru the UI, as I would always do (I am not planning to have any complex triggers), that field would always be there.
But in general, yes, it is best to make sure this works o matter what. I will have to practice a little more on these tests before I move to the next stage
I am getting the error like this on the test case can any body help me to reslove it
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, quoteUpdateopportunity: execution of AfterInsert
caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Trigger.quoteUpdateopportunity: line 10, column 1: []
This is my trigger wrote on quote
this is the test class i wrote
Help me to find out get riid of this error
trigger ADRUserTrigger on ADRUser__c ( after update){
for (ADRUser__c a : Trigger.New) {
if (a.Status__c == 'Submit'
&& a.ApproveReject__c <>'Approved'
&& a.ApproveReject__c <>'Rejected'){
***Note i have a workflow rule to change accept rejected to approved rejected. I thought that this may correct the issue but it doesnt.
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Request has been Submitted ');
req1.setObjectId(a.id);
req1.setNextApproverIds(new Id[] {a.User__c});
Approval.ProcessResult result = Approval.process(req1);
}
}
}
Try @isTest(SeeAllData=true).
Today I got the same error and after little research found that seeAllData Fix this issue.
But really want to help the new ones who will refer this post,
In this case the setup Objects like User, ObjectPermissions, PermissionSet, PermissionSetAssignment, UserRole, etc. are inserted or updated or deleted in the same transaction when DML is performed on non-setup objects or custom or standard objects.
So, to avoid it we need to use on the DML operation in the code - System.runAs(User){ }
here is the reference - salesforce help for setup and non-setup objects DML operations together (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_runas.htm#:~:text=The%20system%20method%20runAs%20enables,runAs%20only%20in%20test%20methods.)