• shubham r 9
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
My Question: If i schedule a batch at 11:59pm
which has query- select records where createddate = today
and the org does not have resources to execute the batch so it gets executed next day say at 00:10am
then records fetched will be of which date?
scheduled date(which was yesterday) or execution date?
Hi all, I want to know if SF will ever reuse the same key prefix on a custom object that has previously been deleted or is it guaranteed to use a new one?

I know, that SF record IDs are globally unique and it will take many million years before SF runs out of them, but what about the object key prefix (or ID) within a single org?

For custom objects, the prefix is 3 characters long, case sensitive and alphanumeric which gives around 240k variations.
Trying to write a test class for the following trigger that gives access to community members for documents under the quotes object. I am just not sure how to test/check in the test class. 

Trigger
trigger shareFilesWithCommunityUsers on ContentDocumentLink(before insert){

   Schema.DescribeSObjectResult r = Quote.sObjectType.getDescribe();
    String keyPrefix = r.getKeyPrefix();

      for(ContentDocumentLink cdl:trigger.new){
        if((String.valueOf(cdl.LinkedEntityId)).startsWith(keyPrefix)){
          cdl.ShareType = 'I';
          cdl.Visibility = 'AllUsers';
          } 
       }
    }

Test Class
@IsTest
Public class TestShareFilesWithCommunityUsers {
    
     static testmethod void testmethod1(){
        

        
           //Create 2 accounts
        List<Account> accounts = new List<Account>();
        Account accA = bg_Account_Test_Utils.createAccount('Influencer', 'Account A');
        accounts.add(accA);
        insert accounts;

        //Create 2 contacts, linked to the accounts
        List<Contact> contacts = new List<Contact>();
        Contact conA = bg_Contact_Test_Utils.createContact('Test', 'Contact A', accA.Id);
        contacts.add(conA);
        insert contacts;

        //Create a project
        Project__c project = bg_Project_Test_Utils.createProject('Test Project 1', 'Education', 'Tender Phase', 'Leeds', 'LS61QF', accA.Id, conA.Id, 'New build project');
        insert project;

        List<Opportunity> opps = new List<Opportunity>();
        Opportunity wonOpp = bg_Opportunity_Test_Utils.createOpportunity('Controlled Environments', 'Opportunity 1', accA.Id, 'Outline Specification', project.Id, Date.Today() + 30);
        opps.add(wonOpp);
        insert opps;
        
        Quote Q = New Quote(Name='Test Quote', OpportunityId=WonOpp.Id);
        insert Q;
        
        ContentDocumentLink contentlink=new ContentDocumentLink();
        contentlink.LinkedEntityId=q.id;
        contentlink.ShareType= 'I';
        contentlink.LinkedEntityId = q.Id; 
        contentlink.Visibility = 'AllUsers'; 
        insert contentlink;
         
   }
}

Sorry Still Trying to Wrap my head around apex. 

We have an existing class that uses the Test.isRunningTest() method.  Today we tried making changes to that class (completely unrelated to the isRunningTestMethod) and weren't able to save it because of a "method doesn't exist or incorrect signature" error on that method.  Did something change with the Winter 12 release where we can no longer use this in code?  If so, is there something replacing this functionality?  If we should still be able to use it, any thoughts on why we are receiving this error now?


Save error: Method does not exist or incorrect signature: Test.isRunningTest()


  • October 27, 2011
  • Like
  • 1