• MythreyeeSS
  • NEWBIE
  • 65 Points
  • Member since 2016
  • Senior Consultant - Technical
  • CSC


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 10
    Replies
I am getting the following error :
Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateActivityOnLeadConverted: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.CreateActivityOnLeadConverted: line 34, column 1: [] Class.leadconvert.BulkLeadConvert.handleOpportunityInserts: line 740, column 1 Class.leadconvert.BulkLeadConvert.convertLead: line 104, column 1

Below is the trigger I think is the problem but not sure Please help.
 
trigger CreateActivityOnLeadConverted on Opportunity (after insert) {
    
    List<Task> tasksToInsert = new List<Task>();
    List<User> usersToUpdate = new List<User>();
    List<Lead_Quota_Audit__c> lstNewAudits = new List<Lead_Quota_Audit__c>();
    
    Id wholsaleID = null;
    List <RecordType> wId = [Select Id From RecordType where sobjecttype = 'Opportunity' and name = 'Wholesale' limit 1];
    if ((wId != null) && (wId.size() == 1)) wholsaleID = wId[0].Id;
    
    Set<Id> userIds = new Set<Id>();
    for(Opportunity opp : Trigger.new){
        userIds.add(opp.OwnerId);
    }
    
    Map<Id, User> usersById = new Map<Id, User>([SELECT Id, Name, Leads_Assigned_Current_Month__c, Leads_Assigned_Current_Week__c FROM User  WHERE Id IN :userIds]);
    
    for(Opportunity opp : Trigger.new){
        if (opp.RecordTypeId != wholsaleID) {    
            if (opp.ConvertedLeadID__c != null) {
                Task task = new Task(
                    Type = 'Call',
                    Subject = 'Lead Status Changed to Converted',
                    ActivityDate = Date.Today(),
                    WhatId = opp.Id,
                    OwnerId = UserInfo.getUserId(),
                    Status = 'Completed', 
                    Call_Screener_Transfered__c = opp.CS_Transferred__c 
                );
                tasksToInsert.add(task);
                if(opp.Lead_Status__c == 'Open'){
                    User u = usersById.get(opp.OwnerId);
                    if(u != null){
                        u.Leads_Assigned_Current_Month__c++;
                        u.Leads_Assigned_Current_Week__c++;
                        usersToUpdate.add(u);
                        Lead_Quota_Audit__c audit = new Lead_Quota_Audit__c(
                            Lead__c = opp.ConvertedLeadID__c,
                            User__c = u.Id,
                            Old_Owner__c = u.Name
                        );
                        lstNewAudits.add(audit);
                        
                    }
                }
            }
        }
    }
    
    insert tasksToInsert;
    update usersToUpdate;
    if(lstNewAudits.size() > 0) {
        insert lstNewAudits;
    }

}

 
The Line: 6, the Column: 1
System. DmlException: Update failed. The First exception on row 0 with id 0032800000 ax478aaa;First error: CANNOT_EXECUTE_FLOW_TRIGGER, unable to save the record, because it triggers the process failure.Flow trigger execution flow with version ID 301280000002 TDJ failure.Flow error message: < b > unable to process the error occurred in this flow < / b > < br > unable to process the error occurred when processing flow.For more information, please contact the system administrator.Please contact your administrator for help.: []


first error: CANNOT_EXECUTE_FLOW_TRIGGER
I want to send salesforce data to another system, but when I send the data through a batch class when I call the web service in the execute method doesn't execute all the batches, but if in the execute method don't make the callout all the batches execute, I put two counters in the execute method and I am showing in the finish method one for the number of records in the list and the other for the times the execute method is running, and when I execute the batch without make the callouts run all the batches but when execute the batch calling the web service in the execute method don't run all the batches.
I am getting the following error :
Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateActivityOnLeadConverted: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.CreateActivityOnLeadConverted: line 34, column 1: [] Class.leadconvert.BulkLeadConvert.handleOpportunityInserts: line 740, column 1 Class.leadconvert.BulkLeadConvert.convertLead: line 104, column 1

Below is the trigger I think is the problem but not sure Please help.
 
trigger CreateActivityOnLeadConverted on Opportunity (after insert) {
    
    List<Task> tasksToInsert = new List<Task>();
    List<User> usersToUpdate = new List<User>();
    List<Lead_Quota_Audit__c> lstNewAudits = new List<Lead_Quota_Audit__c>();
    
    Id wholsaleID = null;
    List <RecordType> wId = [Select Id From RecordType where sobjecttype = 'Opportunity' and name = 'Wholesale' limit 1];
    if ((wId != null) && (wId.size() == 1)) wholsaleID = wId[0].Id;
    
    Set<Id> userIds = new Set<Id>();
    for(Opportunity opp : Trigger.new){
        userIds.add(opp.OwnerId);
    }
    
    Map<Id, User> usersById = new Map<Id, User>([SELECT Id, Name, Leads_Assigned_Current_Month__c, Leads_Assigned_Current_Week__c FROM User  WHERE Id IN :userIds]);
    
    for(Opportunity opp : Trigger.new){
        if (opp.RecordTypeId != wholsaleID) {    
            if (opp.ConvertedLeadID__c != null) {
                Task task = new Task(
                    Type = 'Call',
                    Subject = 'Lead Status Changed to Converted',
                    ActivityDate = Date.Today(),
                    WhatId = opp.Id,
                    OwnerId = UserInfo.getUserId(),
                    Status = 'Completed', 
                    Call_Screener_Transfered__c = opp.CS_Transferred__c 
                );
                tasksToInsert.add(task);
                if(opp.Lead_Status__c == 'Open'){
                    User u = usersById.get(opp.OwnerId);
                    if(u != null){
                        u.Leads_Assigned_Current_Month__c++;
                        u.Leads_Assigned_Current_Week__c++;
                        usersToUpdate.add(u);
                        Lead_Quota_Audit__c audit = new Lead_Quota_Audit__c(
                            Lead__c = opp.ConvertedLeadID__c,
                            User__c = u.Id,
                            Old_Owner__c = u.Name
                        );
                        lstNewAudits.add(audit);
                        
                    }
                }
            }
        }
    }
    
    insert tasksToInsert;
    update usersToUpdate;
    if(lstNewAudits.size() > 0) {
        insert lstNewAudits;
    }

}

 
Trigger not getting fired , using an object from managed package.

Trying to update fields in shipper record after insert from the fields of Sales order record.

here is the code, 

trigger UpdateContactInfo on rstk__soship__c (after insert) {
    System.debug('********trigger is called');
    rstk__soship__c[] shipments = Trigger.new;
    rstk__sohdr__c[] orders = null;
    for(rstk__soship__c shipment:shipments){
        orders = [Select    rstk__sohdr_contact__c, rstk__sohdr_conemail__c,rstk__sohdr_conphone__c 
                  from rstk__sohdr__c 
                  where rstk__sohdr_order__c =: shipment.rstk__soship_order__c ];
        
        System.debug('Here in the for loop shipment ordernumber '+shipment.rstk__soship_order__c);
        
        if(orders.size() > 0){
            System.debug('Found the order order name :'+orders[0].rstk__sohdr_contact__c+
                         'email: '+orders[0].rstk__sohdr_conemail__c+
                         'Phone :'+orders[0].rstk__sohdr_conphone__c);
            shipment.rstk__soship_contact__c = orders[0].rstk__sohdr_contact__c;
            shipment.rstk__soship_email__c = orders[0].rstk__sohdr_conemail__c;
            shipment.rstk__soship_phone__c = orders[0].rstk__sohdr_conphone__c;
         }
    }

}

Any suggestion would be very much appreciated. Thanks,
Hi, 

 Please suggest me what is the mistake in the below code. 
trigger CaptureStatusTimeZone on Task (After Insert,Before Update) {
String timeZone;
Datetime dateGMT;
Datetime d1;
Set<Id> tid = new Set<Id>();

 for(Task T : Trigger.new){
    tid.add(t.id);
   }
 

List<Task> updatetask = new List<Task>();
updatetask = [Select Id,status,createddate,createdbyid,lastmodifieddate,lastmodifiedbyid,
                      lastmodifiedby.TimeZoneSidKey 
              from task where Id in :tid];
List<Task> updatetasks = new List<Task>();

  for(Task ts : updatetask){
  
    if(ts.Status == 'Completed')
    {
     dateGMT = ts.lastmodifieddate;  
     d1 = Datetime.valueOf(dateGMT);
     ts.Status_Completed_Time_Zone_Date__c = d1.format('MM/dd/yyyy HH:mm:ss',ts.lastmodifiedby.TimeZoneSidKey);
     updatetasks.add(ts); 
    }
   }

  update updatetasks;

}

I receive below error 
 
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger CaptureStatusTimeZone caused an unexpected exception, contact your administrator: CaptureStatusTimeZone: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00T1b000002yhaZEAQ; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00T1b000002yhaZ) is currently in trigger CaptureStatusTimeZone, therefore it cannot recursively update itself: []: Trigger.CaptureStatusTimeZone: line 29, column 1
Thanks
Sudhir
 
  • December 06, 2016
  • Like
  • 0
Hi all,

I am using following code to genrate sign, It is working fine in summer 16 salesforce release but my org it autmatically upgraded to winter 17 and this code starts giving follwoing exception:-

"EXCEPTION: System.SecurityException: Invalid Crypto Key
STACKTRACE: Class.System.Crypto.sign: line 35, column 1
AnonymousBlock: line 7, column 1
AnonymousBlock: line 7, column 1
LINE: 35 COLUMN: 1"


can any one help me on this???
string modifiedPrivateKey = 'MIIEpAIBAAKCAQEA1l9J+lUhM3RIADiLy2ajqUjltBqSVMthUlNnu8GsN4z85aniBIDebY+RkFhKDDW9hu8xM/Q4NEI7klmCVWI5BnobWfUjRbhd9oW94qBP7B1Ka6BsSn3RbfvGZZLcDNXd6806acpgMn79fjYPUQPI1kSfrd1GeMDQDGtNFsnCTd9zq2Vye4RQJrlDzC7g70i3jEHCh853ifD4MaQwo+SWf/eF7bLqA+81qUB2llRyA7SH9YF1I/ZmgH57MVTXb62HRMr/JxERDOerHLt7CK9hdbmM3vpRZz8MJnIMrNJKXXbxS69F8aLK7q+8i8xkl1IRwWVD9uJJaWpz7NEBs9EenwIDAQABAoIBACRDLjJoYBtiGiPfbNZVYG3sZN7Yd9RcKvRQI4YBNu6WrNj0qcT1P6rs1ETEipISLSM8JuiQ8Uj1wzn4ZjGnUdokoafP7c2HaG2hJgPF9n8MXWBjXK4lJl4ibucTtqF9M/MFXlIy557jGGJXJrQfncORDCnO+nLGuuq+4+Vs769YQ+bfj69pzfo4kUKaZRj6tgDcAo9Owbe6b7t1gGIM1fo+1fnyZrgYUxwor6periyvjefJaw8N78ASXbu9zHvVrbqaZmwXRJqCRRm8yYigGwQoxLX1DEryrSSCOEZWNUYzG+Det8XuvmsfRkYfw9p/Bz5XO5V70eU5zq5sw6qGkuECgYEA7feem7nGKMFyEVD9st8jhRvOD3n+Z5QAsbaCN5u3GkvXyKXeD7c0RYP4EPtVjEFcB+jy0zktl4Eks+iz7HhGvQhykQx5s5JC5k6P0Rsd+7YOU/8YsuSOvlXnnuclCzpoX1iClYVTJVQ9U7axbE3P07blQ3PqBu1pZ2XPC/sstRkCgYEA5p3xo4/gHQy65qpmh6EHtW2WlQDxbhLBCok8lCEioZaGK9PyNesGsuTcPLU4bj+mch3Yggn7aHfL/zXjdt4K5KWM6wVyK7KNgDisoJzA7fC4u+3VptLjeWKi+xVhPHLmnmuQP3Dq6SDCF2xbuIvynW0jiujdw6NQWYLo+NT+cHcCgYEAvocbvqMnPUplAehOuABgeBqjCVErl9KwG5l8+Pj7yVogEs561Sph96aJ307cV8ec39hrUyLclgkYUdNm+1XxjThOQkQyzMu2NJ+CFnIXt4k0P5xnMhQ9FbfCE0AOMMc6+dvr8bslryWbVINZ2tUSKPiu5yrPnWxIkDi7ZWRdj0ECgYASqR8fZAn3b8tD1O/884vDI332yp++j2ftaVNsjQ3XU23B6CGGOWFOYnRruSI60Y2vWDjntNUSC/eGzB5+xNLO05KGhedKH+WRRYS6blSyLDNWiZUrLY9YiCG1/XHjyUxd70g5yfJIMO1jpdH6KeDU2jrxB4zCQtnClHQzhlCcWwKBgQDGF4JypvYibSkfoiGHQR0Lq3U4l69t5KRcpBYuWdugPdBcdLUOlYOf+6ZPoH+gpk0Awlu+ZqgWfxPTa7eHLxIwCb2Y81bfrCISiUlUUJnPcE7bNrSnoskTQb8flqtGYT94eux0MKktRg6Wojrug/p7kvr7K1zA+zrfjvUK4Rc5LA0K';
string jwtClaims = 'eyJpc3MiOiJ5bnFpNTYzc3hzMDh4ZWR6ajM2a29lenduczZ1ZmRyMCIsInN1YiI6IjI4NTc5Mzg5NCIsImJveF9zdWJfdHlwZSI6InVzZXIiLCJhdWQiOiJodHRwczovL2FwaS5ib3guY29tL29hdXRoMi90b2tlbiIsImp0aSI6InRKVFRwUklmRFhFUlNkNjFBS0hIam9wUm41ZEVSMjBMIiwiZXhwIjoxNDc2MDg4ODA4fQ';
string jwtHeader = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InAwbXE4aHZqIn0';
String algorithmName = 'RSA-SHA256';
Blob input = Blob.valueOf(jwtHeader + '.' + jwtClaims);
Blob privateKeyBlob = EncodingUtil.base64Decode(modifiedPrivateKey);
Blob signed = Crypto.sign(algorithmName, input, privateKeyBlob);
Thanks Anurag
 
I created several process builder proceeses around check boxes on the contact object.  I wanted to trigger these to update in mass so I created a hidden checkbox field on the contact object called 'Mass Update', set the value to true for all and trying to do an update. I got the error: The record couldnt be saved because it failed to trigger a flow. <br>A flow trigger failed to execute the flow with version ID 30116000000PPKL. <br/> Contact your administrator for help.

I don't have any active conflicting workflow rules on these fields.  When I tested the active processes they all individually worked. Why am I getting this for all 16K contacts i'm trying to update using Jitterbit? 

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.