You need to sign in to do that
Don't have an account?
dave_mwi
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY on opportunityContactRole
I am receiving this error when trying to save a trigger to my production SF account:
Here is my trigger. I've tried it on after insert as well:
I've checked my profile permissions and I have 'Modify All' set...any reason why I shouldn't be able to create this new opportunityContactRole? I can't find anything about why I wouldn't with the 'Modify All' permissions set...
Code:
Run test failure marker: resource '': 'System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, opportunityContactRoleUpdate: execution of BeforeInsert
Code:
trigger opportunityContactRoleUpdate on Opportunity (before Insert, before Update) { // Loop over the Opportunities in the 'new' list of the for(Opportunity o : Trigger.new) { // Here we need to do the contsraint check if((o.StageName == 'Closed Won (Recurring)' || o.StageName == 'Pilot (Recurring)') && o.Recurring_Opportunity__c=='Yes' && o.Probability>=90.0 && o.Client_Id__c==4944) { // We need yesterdays Date. First go to the start of the current Month just to be safe. // Then subtract one day. Date a = System.today(); Date b = a.toStartOfMonth(); Date c = b.addDays(-1); // Get the Opportunity that this one was created from using // the client id and a close date of before the first of last month // We are getting a limit of 1, to get the latest. It might not have been // From the last month per se, but the latest excluding this one. List<Opportunity> oldOpps = [SELECT id FROM opportunity WHERE Client_Id__c = :o.Client_Id__c AND closedate <= :c ORDER BY closedate DESC LIMIT 1]; // Get any OpportunityContactRoles attached to the old Opportunity List<OpportunityContactRole> ocrs = [SELECT id, OpportunityId FROM OpportunityContactRole WHERE OpportunityId=:oldOpps[0].id]; // Loop through any found OpportunityContactRole objects and set the OpportunityId // to the OpportunityId of the new Opportunity for(integer i=0; i<ocrs.size(); i++) { OpportunityContactRole new_ocr = new OpportunityContactRole(OpportunityId = o.id,ContactId = ocrs[i].ContactID,Role = ocrs[i].Role); insert new_ocr; } } } }
I've checked my profile permissions and I have 'Modify All' set...any reason why I shouldn't be able to create this new opportunityContactRole? I can't find anything about why I wouldn't with the 'Modify All' permissions set...
All Answers
Hi , Did you you find a solution for this. I am getting the same error message CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Protected_Parts_update: execution of AfterUpdate
caused by: System.QueryException: List has no rows for assignment to SObject
I have a call into the premier support and will update this if they actually have an answer...
Then, there might be issue with your Access or Privilege in Live Enviornment. Do you have the permission to Modify All Data or Records in Live Enviornment. IF not than Admin needs to set this one.. also check if recor exist. Would you mind pasting the Test Method..in post..so we can tell you problem if any
@IsTest private class triggerLicenseTests {
public static testmethod void triggerLicenseTest() {
Test.startTest();
LicenseKey__c keys = [select name, Seats_Allowed__c, BOM_Item__c from LicenseKey__c where name = :'1234567890'];
keys.Seats_Allowed__c = 3;
Database.update(keys);
License__c ano = [select name, license_size__c from License__c where name = :'61'];
ano.license_size__c = 'A6';
Database.update(ano);
Test.stopTest();
}
}
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, licenseCheck: execution of AfterUpdate
caused by: System.Exception: Too many query rows: 501
Trigger.licenseCheck: line 13, column 9
Class.Registration_CheckTEST.test1: line 8, column 9
Cumulative resource usage:
Resource usage for namespace: (default)
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 500
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 100
Number of DML rows: 1 out of 500
Number of script statements: 2 out of 200000
Maximum heap size: 0 out of 500000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 10
Number of record type describes: 0 out of 10
Number of child relationships describes: 0 out of 10
Number of picklist describes: 0 out of 10
Number of future calls: 0 out of 10
Number of find similar calls: 0 out of 10
Number of System.runAs() invocations: 0 out of 20
Total email recipients queued to be sent : 0
Stack frame variables and sizes:
Frame0
*** Ending Test Registration_CheckTEST.public static testMethod void test1()
public class Registration_CheckTEST {
public static testmethod void test1() {
//Test.startTest();
Registered_Pen__c pens = new Registered_Pen__c(Name='Test Oppt', key_registered_with__c='a0o700000007FfBAAU', product_pen_registered_for__c='xxxxxxx');
insert pens;
Message Edited by James_Adapx on 12-02-2008 01:24 PM
It might have too many records in Live Enviorment.. not sure what exactly your trigger contains. can you past trigger as well as Method.
one more thing you can use LIMIT 1 in SOQL to restrict just one rows..
cellx = [select count() from LicenseKey__c where OrderDetail__c = null and BOM_Item_Name__c = :setting.Cellx_BomItemName__c];
no it wont have an issue,. do a count to see how much comes..
anyway Gud luck.. deployment is really fun. In last project I spent more time in Test Method and Deployment rather than Development
Really helpfull tool..