Category Archives : Apex

What Are the Available Static Code Analysis Tools for Apex?

On March 18, 2025, Posted by , In Apex,Salesforce Technical Questions, With Comments Off on What Are the Available Static Code Analysis Tools for Apex?

Question What Are the Best Static Code Analysis Tools for Apex? I’m looking for static code analysis tools specifically designed for Apex development. While the Force.com Security Source Code Scanner is a well-known option, it has the limitation of operating through a queue system, which can delay the analysis. I’m…

Can the Metadata API Be Invoked from Apex?

On March 16, 2025, Posted by , In Apex,Salesforce Technical Questions, With Comments Off on Can the Metadata API Be Invoked from Apex?

Question: Is it possible to use the Salesforce Metadata API from within Apex? Can the Metadata API be invoked from Apex? Many sources state that Salesforce doesn’t allow callouts to its own web services from within Salesforce. However, other posts and resources suggest it might be achievable, especially for specific…

How to generate a GUID/UUID in Apex?

On March 14, 2025, Posted by , In Apex, With Comments Off on How to generate a GUID/UUID in Apex?

Question: What is the best way to generate a GUID/UUID in Apex, particularly in the format nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn? For example, a valid UUID might look like 13219ec0-3a81-44c5-a300-de14b7d0235f. This functionality would be useful in scenarios like assigning unique identifiers to records in triggers. Answer: Below is a reusable class in Apex for…

Dynamic Scale for Currency Field in Salesforce?

On March 10, 2025, Posted by , In Apex,Salesforce, With Comments Off on Dynamic Scale for Currency Field in Salesforce?

Question How to Correctly Create a Transaction Security Policy via the Tooling API? I am attempting to create a Transaction Security Policy using the Tooling API, but I’m facing challenges with the JSON structure. I’ve tried several variations, but none seem to work. Below are my attempts and the errors…

Deserializing JSON with Reserved Words as Properties in Apex

On March 10, 2025, Posted by , In Apex,Salesforce Technical Questions, With Comments Off on Deserializing JSON with Reserved Words as Properties in Apex

Question How to Deserialize JSON with Reserved Words as Property Names in Apex? Is there a way to deserialize JSON into an Apex object using JSON.deserialize, even if some of the property names in the JSON correspond to reserved keywords in Apex? For example, when deserializing JSON with reserved words,…

How to debug Apex code effectively?

On March 10, 2025, Posted by , In Apex,Salesforce Technical Questions, With Comments Off on How to debug Apex code effectively?

Question: I’m new to Salesforce development and would like to learn how to debug my Apex code effectively. I often encounter issues in my triggers and controllers but struggle to identify the root causes. What steps or tools can I use to output debug information, investigate issues, and resolve errors…

Does setting a lookup field trigger a SOQL query?

On March 9, 2025, Posted by , In Apex,Salesforce Technical Questions, With Comments Off on Does setting a lookup field trigger a SOQL query?

Question: When working with Apex, a common question that arises is whether creating a new record with a lookup field will trigger a SOQL query. For example, if you create a new Contact and assign it to a lookup field of a Case record, does it result in a SOQL…

Can Data Streams be created via Apex in Tests?

On March 8, 2025, Posted by , In Apex, With Comments Off on Can Data Streams be created via Apex in Tests?

Question How to Test Data Stream Creation via Apex in a Test Class? I am trying to create and test Data Streams in Apex within a test class, but I’ve encountered challenges and errors during execution. Here’s the scenario: In my Apex Controller, I query for Data Streams (and other…

How to Clone a Record with Related Lists?

On March 6, 2025, Posted by , In Apex,Salesforce Technical Questions, With Comments Off on How to Clone a Record with Related Lists?

Question: I need to clone all Account records along with their associated Contact records. I am using the clone() method in Apex for this. Below is the code I have written: I am unable to figure out how to associate the cloned contacts with the corresponding cloned accounts. Since the…

How to Run a Scheduled Job Every 15 Minutes?

On March 5, 2025, Posted by , In Apex,Salesforce Technical Questions, With Comments Off on How to Run a Scheduled Job Every 15 Minutes?

Question: Salesforce’s built-in GUI for scheduling jobs does not allow setting an interval shorter than one day. However, I need to run a scheduled job every 15 minutes. How can I achieve this in Apex? CRS Info Solutions offers industry-leading Salesforce training in Singapore with real-time projects, Salesforce training certification guidance, interview coaching, and…