Skip to main content

Posts

When running Anonymous apex, Seeing the error "This org has reached its daily usage limit of apex log headers"

All API calls that invoke Apex,  support a debug facility that allows access to detailed information about the execution of the code. We use the Categories and Level fields of DebuggingHeader of the request to see the logging granularities. Sample DebuggingHeader   <urn:DebuggingHeader> <!--Zero or more repetitions:--> <urn:categories> <urn:category>Apex_code</urn:category> <urn:level>FINEST</urn:level>  </urn:categories> <urn:categories> <urn:category>Apex_profiling</urn:category> <urn:level>FINER</urn:level> </urn:categories> </urn:DebuggingHeader> The debugLog field of DebuggingInfo response header contains the debug logs based on the log level set in the request. The error " This org has reached its daily usage limit of apex log headers " occurs when you run too many API calls that request the Debugging information for the execution of code.  Salesforce limits the numb

Track the components deployed in salesforce

 As an admin, Sometimes we might need to track what are all the components getting deployed in Salesforce. We can monitor the Deployment Status via Set up. The Screen only shows the deployment information and Component Errors.  Successful Deployment: Failed Deployment: But what if needed to track the components that were deployed? To track the components deployed, We can use the below Metadata Rest API endpoint. /services/data/vXX.0/metadata/deployRequest/deployRequestId?includeDetails=true In the workbench, Go to Utilities --> Rest Explorer and Make a Get call with the endpoint and deployment id. /services/data/v50.0/metadata/deployRequest/0Af2C00000h4yk?includeDetails=true In the below response, We can see that Under Details, We have ComponentFailures, ComponentSuccess and allComponentMessages. I hope this helps. Thank you for your time in reading this article. Cheers :)

Facing issues in scheduling an apex class?

When trying to schedule an apex class, We are facing the scheduled apex exception ' Error: You must select an Apex class that implements the Schedulable interface. ' In our scenario, We have noticed that the class which we are trying to schedule is invalid . This was the reason for the above error. Usually Classes and triggers are marked as valid, as long as dependent metadata has not changed since the class was last compiled. If any changes are made to Object names or Fields that are used in the class, including superficial changes such as edits to an Object or Field description, or if changes are made to a class that calls this class, the isValid flag is set to false. From below query you can check which other classes or triggers are set as inValid: Select Id, Name from ApexClass where isValid = false Select Id, Name from ApexTrigger where isValid = false Compiling all classes can fix this issue.  To compile Classes: Go to Setup | Develop | Apex Classes   For LEX - Setup | Cu

Too Many redirects error for Salesforce domain URL

When accessing the Salesforce pages, you may experience an issue where an infinite loop occurs and blank page appears. This could typically result in errors such as : Redirected you too many times ERR_TOO_MANY_REDIRECTS Solution : 1. This could be issue where the cookie needed for Salesforce is blocked by the browser application. To allow the cookies, Go to cookie settings with this link chrome://settings/cookies Add the following sites in the setting 'Sites that can always use cookies' [*.]lightning.com [*.]force.com [*.]salesforce.com [*.]salesforce-communities.com [*.]trailhead.com [*.]visualforce.com 2. Due to Session Setting --> "Lock sessions to the IP address from which they originated" Enabling the above setting can cause  too many redirect errors, When the customer's login IP does not match the remote address IP in the request. 3. Instance Refresh  An instance name identifies where your Salesforce org is hosted. During instance refresh, Your org is mig

Encrypted fields show unencrypted value when accessing via apex

When querying records in Apex,  the result includes raw values instead of a mask for encrypted fields even though the user does not have access to view the encrypted data. This results in a UI displaying actual data because the UI is using Apex.  Steps to reproduce : Create a new custom object named Sample Create a custom field on object Sample named Sensitive__c and set the type to Text (Encrypted) Create a new record in the custom object Sample and set the Encrypted__c field to the value TEST Save the record. Observe that if your profile don't have  View Encrypted Data permission, you see a field mask on the field Sensitive__c on the detail page  If you see the value TEST and you do not see the mask, Then your profile has View Encrypted Data permission. Remove View Encrypted Data permission from your profile so that field mask on the field Sensitive__c appear. Create a new Apex class na

Time limit exceeded error when changing lookup field into Master detail

 When changing a Lookup field into Master-detail, The conversion process can time out in the UI. You will see ' Time limit exceeded '. This is because all setup operations done on the UI has time limit of 2 minutes. For some organization where we have a lot of data on Child records, This operation runs more than 2 mins and error  out. Reason : As part of the field conversion, There are a lot of activities/checks to be done internally. One of them, is to recreate the sharing/access to the child object.  In our scenario, The Organization has a lot of sharing entries created on the child objects. Since the child records access should be controlled by Parent, The conversion usually deletes all the previous sharing entries created on the Child object. This can take more time depends on how big the sharing table is in the organization. Solution To use either Change Set or Metadata API to deploy the field type's change, since the operation will run in asynchronously. Hope this hel

Why System.CalloutException: Unable to tunnel through proxy. Proxy returns “HTTP/1.1 503 Service Unavailable” occur

When we make authenticated web service callout from Salesforce, the call sometimes fails with this error "Unable to tunnel through proxy. Proxy returns “HTTP/1.1 503 Service Unavailable". The error usually comes when the Firewall at the external system blocks the calls made from Salesforce. So The request never reach the web-service hosted at the external server and get the response back. Below are few of the reasons that could cause this issue. Check if your firewall is configured to allow the traffic from Salesforce . Whitelist Salesforce IP ranges in your firewall. . Here is the document from Salesforce regarding Whitelisting Salesforce IPs Could be a certificate issue.  The certificate might be an expired one. The certificate chain should be valid in correct order and trusted by Salesforce. The order of certificate should be Server certificate --> Intermediate certificate that signed the server's certificate --> Next Intermediate certificate and so on till the

When Service Unavailable Page displayed in Salesforce Communities

 The Service Not Available page appears when the site is not available because of a service outage.  When the site is up and running, the page has no impact on the user’s experience of the site. Follow this document to set up   Service Not Available page in Experience builder site. Note that This feature is available for sites that have enabled the standard content delivery network (CDN) system with a custom URL set for your site. To enable Experience Cloud CDN, Follow this document Note that Experience Cloud CDNs are supported in production environments. They aren’t supported in Developer or Partner Developer editions because they don’t support custom domains. They also aren’t supported in sandbox environments. Below are the couple of reasons why the page can be displayed. 1. Service Unavailable Error could occur because of Server/Instance Service disruption. The service disruption can be monitored via https://status.salesforce.com/ 2. When Special characters like "<

Search for a picklist value in an org

We have a scenario where we need to search for any picklist which has a value 'Banking' in an organization. To find out this value, We are going to use Schema Class and Schema Namespace which has classes and methods to get the list of objects, fields and picklist values. Schema Class (from System Namespace) c ontains methods for obtaining schema describe information. Schema Namespace  provides classes and methods for schema metadata information. To read more,  check  Schema Class   and  Schema Namespace   Below is the sample code to search for a picklist value 'Banking' across the org.  List < Schema.SObjectType > gd = Schema.getGlobalDescribe().Values();        for ( Schema.SObjectType f : gd ) {       Schema.DescribeSObjectResult dsr = f.getDescribe();        Map<String , Schema.SObjectField > mapFieldList = dsr.fields.getMap();         for ( Schema.SObjectField field : mapFieldList.values() ) {             Schema.DescribeFieldResult fieldResult = f

Username and password parameters no longer works in the login URL

  Before Winter 22 release, Salesforce allowed the user to login  by using a username and password as GET query string parameters to the login URL.  This provided a useful trick where users normally bookmark the login url with credentials for easily login into different orgs. Login URL : https://<SFDC Instance Url>/ Parameters 1. Un - Username 2. pw - password e.g. login directly into production org. https://login.salesforce.com/?un=yourname%40salesforce.com&pw=test12345 As per the Winter 22 release ,  To improve the security, Users can no longer log in to Salesforce by using a username and password as GET query string parameters to the login URL. Users who attempt to log in using a GET query string are redirected to a login page.  Thank you for your time in reading this. Cheers :)