• Season1224
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
For the past week or so, our org has been maxing out our API calls.  After doing some investigation, there's something running through my account that's making over 30K calls per day.  I thought it was two triggers I had written but I deleted both of those, and their related classes, and the issue hasn't resolved itself.  Other than those two things, there's nothing else I know of installed through my account. 

My main question is how can I track down the program making these calls??  Since there's no Client ID, I don't know how to go about figuring out what's doing this so I can stop it.  I submitted a support case to see if SF could help but they are now telling me that I will have to upgrade our support level in order for them to investigate.

 User-added image

Any help or direction regarding what to do next would be MUCH APPRECIATED!!!

So I got this trigger working (with the help of some nice members of this board!!!) but now, in production, I'm running into a System.LimitException error.  I believe my problem is with the section where I'm pulling all of the Task IDs into a set (starts at row 5).  However, I'm having trouble figuring out how to correct the problem.  After much googling and trolling on the boards, it seems like I need to create a map first (?) but I'm getting lost when I try to modify my code to do so.  

 

Thanks in advance for any help you can offer!!

 

trigger OppCloseDate on Opportunity (after update) {

Set<Id> oppIds = new Set<Id>();
Set<Id> taskIds = new Set<Id>();{
for(Task t:[select Id, WhatID from Task where Role_AM__c = 'TRUE']){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006')){
            taskids.add(t.WhatId);
for(Opportunity to:[select Id from Opportunity where Id in :taskIds]){
        oppIds.add(to.ID);
    }
    Set<Id> oppstoupdate = new Set<Id>();
    for(Integer i=0;i<trigger.new.size();i++){
        if(oppIds.contains(trigger.new[i].Id)){
            oppstoupdate.add(Trigger.new[i].id);

if(oppstoupdate.size() > 0){

   List<Opportunity> oList = [select Id, CloseDate from Opportunity where Id in :oppstoupdate];
    
   List<Task> taskstoupdate = new List<Task>();{
   for(Task tsk : [select Id, Opportunity_Close_Date__c from Task where WhatId in :oppstoupdate]){
   tsk.Opportunity_Close_Date__c = oList[0].CloseDate;
   taskstoupdate.add(tsk);
            }
        }
             if(!taskstoupdate.isEmpty()){
            update taskstoupdate;
        }
        }
        }
        }
        }
        }
        }
        }

 

 

Hi,

This is my first post on the board and am hoping someone can help!

I created a trigger to populate a custom Task field (Opportunity_Close_Date__c) with the Opportunity Close Date. 

Below please find my trigger and the test class I wrote.

 

The problem is that I'm getting 100% code coverage but the test is failing (Error Message: System.AssertException: Assertion Failed).

 

Any ideas or help would be greatly appreciated!!

Thanks!

 

Here's the trigger:

 

trigger OppCloseDate on Opportunity (after insert, after update) {

Set<Id> oppIds = new Set<Id>();
Set<Id> taskIds = new Set<Id>();{
for(Task t:[select Id, WhatID from Task]){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006')){
            taskids.add(t.WhatId);
for(Opportunity to:[select Id from Opportunity where Id in :taskIds]){
        oppIds.add(to.ID);
    }
    Set<Id> oppstoupdate = new Set<Id>();
    for(Integer i=0;i<trigger.new.size();i++){
        if(oppIds.contains(trigger.new[i].Id)){
            oppstoupdate.add(Trigger.new[i].id);

if(oppstoupdate.size() > 0){

   List<Opportunity> oList = [select Id, CloseDate from Opportunity where Id in :oppstoupdate];
    
   List<Task> taskstoupdate = new List<Task>();{
   for(Task tsk : [select Id, Opportunity_Close_Date__c from Task where WhatId in :oppstoupdate]){
   tsk.Opportunity_Close_Date__c = oList[0].CloseDate;
   taskstoupdate.add(tsk);
            }
        }
             if(!taskstoupdate.isEmpty()){
            update taskstoupdate;
        }
        }
        }
        }
        }
        }
        }
        }

 

And here's the test class:

 

@isTest

private class Test_OppCloseDate {
  
    public static testMethod void myUnitTest(){

 List<Opportunity> opp1 = new List<Opportunity>{ new Opportunity(
        Name = 'Test Opp1',
        StageName = 'Closed Won',
        Type = 'New Business',
        CloseDate = Date.today()+7,
        Demo_ID__c = NULL,
        LicenseType__c = 'Enterprise')};                                
       
    insert opp1;
 
List<Opportunity> opp2 = new List<Opportunity>{ new Opportunity(
        Name = 'Test Opp2',
        StageName = 'Closed Won',
        Type = 'New Business',
        CloseDate = Date.today()+2,
        LicenseType__c = 'Enterprise')};                                
       
    insert opp2;

List<Task> tsk1 = new List<Task>{ new Task(
    WhatId = opp1[0].id,
    Subject = 'Task 2',
    Status = 'Not Started',
    Priority = 'Normal',
    Type = 'Demonstration - In Person')};                                
        
    insert tsk1;
    
  
List<Task> tsk2 = new List<Task>{ new Task(
    WhatId = NULL,
    Subject = 'Task 2',
    Status = 'Not Started',
    Priority = 'Normal',
    Type = 'Demonstration - Web/Phone')};                                
        
    insert tsk2;
    
List<Opportunity> oppstoupdate1 = New List<Opportunity>{ [select id from Opportunity where id in :opp1]};
    for(Opportunity oOP:oppstoupdate1)
    oOP.CloseDate = Date.today();
        Update oppstoupdate1;

List<Task> taskstoupdate2 = New List<Task>{ [select id from task where id in :tsk2]};
    for(task tOK:taskstoupdate2)
    tOK.WhatId = opp2[0].id;
        Update taskstoupdate2;


Task [] tasks1 = [select ID, Opportunity_Close_Date__c from Task where ID in :tsk1];
    System.assert(tasks1[0].Opportunity_Close_Date__c == (opp1[0].CloseDate));

Task [] tasks2 = [select ID, Opportunity_Close_Date__c from Task where ID in :tsk2];
    System.assert(tasks2[0].Opportunity_Close_Date__c == (opp2[0].CloseDate));  
 }
 }

 

 

For the past week or so, our org has been maxing out our API calls.  After doing some investigation, there's something running through my account that's making over 30K calls per day.  I thought it was two triggers I had written but I deleted both of those, and their related classes, and the issue hasn't resolved itself.  Other than those two things, there's nothing else I know of installed through my account. 

My main question is how can I track down the program making these calls??  Since there's no Client ID, I don't know how to go about figuring out what's doing this so I can stop it.  I submitted a support case to see if SF could help but they are now telling me that I will have to upgrade our support level in order for them to investigate.

 User-added image

Any help or direction regarding what to do next would be MUCH APPRECIATED!!!

So I got this trigger working (with the help of some nice members of this board!!!) but now, in production, I'm running into a System.LimitException error.  I believe my problem is with the section where I'm pulling all of the Task IDs into a set (starts at row 5).  However, I'm having trouble figuring out how to correct the problem.  After much googling and trolling on the boards, it seems like I need to create a map first (?) but I'm getting lost when I try to modify my code to do so.  

 

Thanks in advance for any help you can offer!!

 

trigger OppCloseDate on Opportunity (after update) {

Set<Id> oppIds = new Set<Id>();
Set<Id> taskIds = new Set<Id>();{
for(Task t:[select Id, WhatID from Task where Role_AM__c = 'TRUE']){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006')){
            taskids.add(t.WhatId);
for(Opportunity to:[select Id from Opportunity where Id in :taskIds]){
        oppIds.add(to.ID);
    }
    Set<Id> oppstoupdate = new Set<Id>();
    for(Integer i=0;i<trigger.new.size();i++){
        if(oppIds.contains(trigger.new[i].Id)){
            oppstoupdate.add(Trigger.new[i].id);

if(oppstoupdate.size() > 0){

   List<Opportunity> oList = [select Id, CloseDate from Opportunity where Id in :oppstoupdate];
    
   List<Task> taskstoupdate = new List<Task>();{
   for(Task tsk : [select Id, Opportunity_Close_Date__c from Task where WhatId in :oppstoupdate]){
   tsk.Opportunity_Close_Date__c = oList[0].CloseDate;
   taskstoupdate.add(tsk);
            }
        }
             if(!taskstoupdate.isEmpty()){
            update taskstoupdate;
        }
        }
        }
        }
        }
        }
        }
        }

 

 

Hi,

This is my first post on the board and am hoping someone can help!

I created a trigger to populate a custom Task field (Opportunity_Close_Date__c) with the Opportunity Close Date. 

Below please find my trigger and the test class I wrote.

 

The problem is that I'm getting 100% code coverage but the test is failing (Error Message: System.AssertException: Assertion Failed).

 

Any ideas or help would be greatly appreciated!!

Thanks!

 

Here's the trigger:

 

trigger OppCloseDate on Opportunity (after insert, after update) {

Set<Id> oppIds = new Set<Id>();
Set<Id> taskIds = new Set<Id>();{
for(Task t:[select Id, WhatID from Task]){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006')){
            taskids.add(t.WhatId);
for(Opportunity to:[select Id from Opportunity where Id in :taskIds]){
        oppIds.add(to.ID);
    }
    Set<Id> oppstoupdate = new Set<Id>();
    for(Integer i=0;i<trigger.new.size();i++){
        if(oppIds.contains(trigger.new[i].Id)){
            oppstoupdate.add(Trigger.new[i].id);

if(oppstoupdate.size() > 0){

   List<Opportunity> oList = [select Id, CloseDate from Opportunity where Id in :oppstoupdate];
    
   List<Task> taskstoupdate = new List<Task>();{
   for(Task tsk : [select Id, Opportunity_Close_Date__c from Task where WhatId in :oppstoupdate]){
   tsk.Opportunity_Close_Date__c = oList[0].CloseDate;
   taskstoupdate.add(tsk);
            }
        }
             if(!taskstoupdate.isEmpty()){
            update taskstoupdate;
        }
        }
        }
        }
        }
        }
        }
        }

 

And here's the test class:

 

@isTest

private class Test_OppCloseDate {
  
    public static testMethod void myUnitTest(){

 List<Opportunity> opp1 = new List<Opportunity>{ new Opportunity(
        Name = 'Test Opp1',
        StageName = 'Closed Won',
        Type = 'New Business',
        CloseDate = Date.today()+7,
        Demo_ID__c = NULL,
        LicenseType__c = 'Enterprise')};                                
       
    insert opp1;
 
List<Opportunity> opp2 = new List<Opportunity>{ new Opportunity(
        Name = 'Test Opp2',
        StageName = 'Closed Won',
        Type = 'New Business',
        CloseDate = Date.today()+2,
        LicenseType__c = 'Enterprise')};                                
       
    insert opp2;

List<Task> tsk1 = new List<Task>{ new Task(
    WhatId = opp1[0].id,
    Subject = 'Task 2',
    Status = 'Not Started',
    Priority = 'Normal',
    Type = 'Demonstration - In Person')};                                
        
    insert tsk1;
    
  
List<Task> tsk2 = new List<Task>{ new Task(
    WhatId = NULL,
    Subject = 'Task 2',
    Status = 'Not Started',
    Priority = 'Normal',
    Type = 'Demonstration - Web/Phone')};                                
        
    insert tsk2;
    
List<Opportunity> oppstoupdate1 = New List<Opportunity>{ [select id from Opportunity where id in :opp1]};
    for(Opportunity oOP:oppstoupdate1)
    oOP.CloseDate = Date.today();
        Update oppstoupdate1;

List<Task> taskstoupdate2 = New List<Task>{ [select id from task where id in :tsk2]};
    for(task tOK:taskstoupdate2)
    tOK.WhatId = opp2[0].id;
        Update taskstoupdate2;


Task [] tasks1 = [select ID, Opportunity_Close_Date__c from Task where ID in :tsk1];
    System.assert(tasks1[0].Opportunity_Close_Date__c == (opp1[0].CloseDate));

Task [] tasks2 = [select ID, Opportunity_Close_Date__c from Task where ID in :tsk2];
    System.assert(tasks2[0].Opportunity_Close_Date__c == (opp2[0].CloseDate));  
 }
 }