Thursday 28 June 2018


                             Test.isRunningTest()

Test.isRunningTest() This is not used in test classes but in other classes in order to verify if the call is from a test class.

When we are setting up test data from Apex test method, we need a way to disable the triggers that will fire. It might cause "LimitException: "Too many SOQL queries: 101".  In this case, the triggers are not the target of the test case, hence this scenario will cause the test method to fail

Setup up the trigger by leveraging isRunningTest(). isRunningTest() - Returns true if the currently executing code was called by code contained in a test method, false otherwise. Use this method if you need to run different code depending on whether it was being called from a test.


if(Test.isRunningTest()){
//do something
}


Other Usage scenarios
1. To ensure the trigger doesn't execute the batch if Test.IsRunningTest() is true, and then test the batch class with it's own test method.
2. Testing callouts - in your callout code you check to see if you're executing within a unit test context by checking Test.isRunningTest() and instead of getting your callout response from an HttpResponse.send() request, you return a pre-built test string instead.



Maximum number of  Master details and Lookup Creation 


  • Master-Detail Relationship Fields, per Object (Standard or Custom) -- 2
  • Total Relationship Fields (Master-Detail + Lookup), per Object (Standard or Custom) -- 40


Maximum lookup relationships can be 38, 39 or 40 depending on how many master detail relationships have been created so far. 

Sunday 3 June 2018

Developer console: Total Requests Limit Exceeded  error

When I load the developer console, I get a "Total Requests Limit Exceeded" error.





Its because you've ran into your API Limit for the 24-period.
                                            
   Check this: setup àsystem overview

Solution:

You API Usage will be on the top right. If you are at your maximum, I suggest calling Salesforce-Support immediately, and ask to get your API Limits increased temporarily. SF-Support is generally friendly and will usually grant the request. (If you have 5,000 API calls/day, ask for an increase to 10,000 temporarily).

Screen shot of System Overview Link: