• Jason Walstad 2
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
I have a custom object with several custom list views. On the standard 'All' list view, there are a total of 339 records shown (the correct amount). When I navigate to certain other list views for this object, I receive an incorrect record count (for example, 1555). If I set the window to show up to 200 records per page, only a handful of records are displayed (i.e. there are obviously not 1555 records to be shown).

There is no common filter or theme between the custom list views. They all check for different critera and set different visibilities to users. There also doesn't appear to be any functional disruption due to this bug, but it has caused some concern and I am looking to find a possible root cause for its appearance.

What could cause this inconsistency in record count?

It is worth nothing this org hosts a rather large managed package for an application that leverages the Salesforce platform. These object records are a critical component to the function of that package.
Hi all,

I am working on a trigger on the Contract object which creates Events and Orders associated with the activation of a contract. My trigger is throwing an error when I try to assign the ContractId to my newly created Order object. The error does not occur when I assign the ContractId to my Event object, however. Any tips on how to work around this?

Here are some code snippets (Note that 'temp' is a local variable of type Contract):

This code generates the error:
Order o1 = new Order(AccountId = temp.AccountId, EffectiveDate = temp.Requested_First_Service__c, 
                                 ContractId = temp.Id, <---PROBLEM CODE
                                 Status = 'Draft');
Accompanying Event creation code, this does not generate an error:
Event e1 = new Event(WhatId = temp.AccountId, AccountOrSite__c = temp.AccountId, 
                                 Contract__c = temp.Id, 
                                 StartDateTime = temp.Requested_First_Service__c, EndDateTime = te                                        mp.Requested_First_Service__c + 7, 
                                 Subject = 'Initial Followup');

Here is the error generated:
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger StaggeredEventCreation caused an unexpected exception, contact your administrator: StaggeredEventCreation: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 8003B000000DDyx) is currently in trigger StaggeredEventCreation, therefore it cannot recursively update itself: []: Trigger.StaggeredEventCreation: line 67, column 1".
Any tips?
Thank you.


 
Hi all,

I have a simple trigger on the Contract object designed to create a new Event when the contract status is updated to 'Activated'. 
However, the Events do not seem to be created by my trigger. I cannot pinpoint the reason why these Events are not being properly created.

Here is the error generated by my test class: System.AssertException: Assertion Failed: Expected: 0, Actual: 4
Can anyone help?

Trigger code:

trigger StaggeredEventCreation on Contract(before update){
    
    //All contract records which activated the trigger
    List<Contract> c = Trigger.new;
    
    //Only update those records which had a status change to 'Activated'
    for (Contract temp : c){
        if (temp.Status == 'Activated' && temp.Status != Trigger.oldMap.get(temp.ID).Status){
            Event e1 = new Event(OwnerId = '', 
                                 StartDateTime = Datetime.Now(), EndDateTime = Datetime.Now() + 7, Subject = 'Initial Followup');
            Event e2 = new Event(OwnerId = '', 
                                 StartDateTime = Datetime.Now() + 30, EndDateTime = Datetime.Now() + 37, Subject = '30-Day Followup');
            Event e3 = new Event(OwnerId = '', 
                                 StartDateTime = Datetime.Now() + 60, EndDateTime = Datetime.Now() + 67, Subject = '60-Day Followup');
            Event e4 = new Event(OwnerId = '', 
                                 StartDateTime = Datetime.Now() + 90, EndDateTime = Datetime.Now() + 97, Subject = '90-Day Followup');
        }
    }

Apex test class code:

@isTest

private class StaggeredEventCreationTest{
    
    @isTest static void validateStaggeredEventCreation(){
        
        Contract c = new Contract(AccountId = '', StartDate = Date.today(),
                                  ContractTerm = 12, Status = 'Draft');
        insert c;
        
        
        c.Status = 'Activated';
        update c;
        
        Integer eventCount = [SELECT count() FROM Event];
        
        System.assertEquals(eventCount, 4);
    }
}
 
Hi all,

I am working on a trigger on the Contract object which creates Events and Orders associated with the activation of a contract. My trigger is throwing an error when I try to assign the ContractId to my newly created Order object. The error does not occur when I assign the ContractId to my Event object, however. Any tips on how to work around this?

Here are some code snippets (Note that 'temp' is a local variable of type Contract):

This code generates the error:
Order o1 = new Order(AccountId = temp.AccountId, EffectiveDate = temp.Requested_First_Service__c, 
                                 ContractId = temp.Id, <---PROBLEM CODE
                                 Status = 'Draft');
Accompanying Event creation code, this does not generate an error:
Event e1 = new Event(WhatId = temp.AccountId, AccountOrSite__c = temp.AccountId, 
                                 Contract__c = temp.Id, 
                                 StartDateTime = temp.Requested_First_Service__c, EndDateTime = te                                        mp.Requested_First_Service__c + 7, 
                                 Subject = 'Initial Followup');

Here is the error generated:
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger StaggeredEventCreation caused an unexpected exception, contact your administrator: StaggeredEventCreation: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 8003B000000DDyx) is currently in trigger StaggeredEventCreation, therefore it cannot recursively update itself: []: Trigger.StaggeredEventCreation: line 67, column 1".
Any tips?
Thank you.