Pages

Friday, February 28, 2025

CRM Analytics: Long Text Area field only show 255 chars

The Long Text Area field or Rich Text Area field allows users to enter up to 131,072 characters on separate lines, which by default is 32,768 when creating the field. However, the table widget in CRM Analytics only shows 255 characters. What is the cause?

By default, Precision is blank in the sync setup; you can navigate from Data Manager >>  Connections >> SFDC_LOCAL, click the object name, click the pencil icon next to the field name, enter the length of the characters as you need in the Precision box.








Thursday, February 27, 2025

Case fields that cannot be removed from page layout

In Salesforce, certain Case standard fields cannot be removed from the case page layout; these fields are marked with a blue dot when you open the case page layout:

 

  • Contact Name
  • Status
  • Priority
  • Case Origin
  • Subject
  • Description
  • Web Email

dsds
If you upgrade the form to a dynamic layout, the restriction to always show the fields is no longer applicable.





Friday, February 21, 2025

CRM Analytics: Calculate aging excluding weekends in Dataflow

We shared the Salesforce formula field to calculate aging without the weekend here. But can we replicate it in CRM Analytics? 

Here is the formula using dataflow in compute expression:

Full_Weeks (in Numeric)
floor(date_diff("day", toDate(CreatedDate_sec_epoch), toDate(CloseDate_sec_epoch))/7) * 5

Remaining_Days (in Numeric)
date_diff("day", toDate(CreatedDate_sec_epoch), toDate(CloseDate_sec_epoch)) % 7

Start_Day (in Numeric)
day_in_week(toDate(CreatedDate_sec_epoch))

Weekend_Adjustment (in Numeric)
case when (Start_Day + Remaining_Days) > 7 then 2 
     when (Start_Day + Remaining_Days) == 7 then 1 else 0 end

Business_Days_Aging
Full_Weeks + Remaining_Days - Weekend_Adjustment




Wednesday, February 12, 2025

Convert SOQL result Date/Time field to Excel

Sample: SELECT Id, CreatedDate FROM Account

Result of CreatedDate: 2024-08-14T14:48:05.000+0000

To Convert into Excel as Date/Time format:

  1. Formula =VALUE(SUBSTITUTE(LEFT(A2, 19), "T", " "))
  2. Format Cells... (or Ctrl+1) for the above formula cell, select Custom, and Type: yyyy-mm-dd hh:mm:ss
  3. Done 




Monday, November 11, 2024

CRM Analytics: Recipe formula syntax in Transform node

For those who have used Dataflow in the past and migrated to Recipe recently, some of the syntax and functions are different from SAQL in Dataflow.

1. string
use ' instead of "
in SAQL, case when 'Data.Name' is null then "No" else "Yes" end
in the recipe, case when "Data.Name" is null then 'No' else 'Yes' end


2. operand in comparison
in the recipe, equal, use = instead of ==
unequal, use !=


3. operand logic
in the recipe, use AND or OR


4.  instr() to replace index_of() 
Syntax: instr(field, searchString, [position, [occurrence]])
instr('123!456!78!', !) -- the result is 4
instr('123!456!8!', !, [4])  -- the result is 7
instr('123!456!8!', !, [4, [2]])   -- the result is 9
case when instr(Email, '@ap') > 0 then 'APAC' when instr(Email, '@eu') > 0 then 'EMEA' else 'AMER' end


5. to_timestamp() to replace toDate()
in SAQL, case when 'Region' == "APAC" then toDate("2024-01-06 21:00:00") 
else toDate("2024-01-07 11:00:00") end

in the recipe, case when "Region" = 'APAC' then to_timestamp('2024-01-06 21:00:00') else to_timestamp('2024-01-07 11:00:00') end

The output type from to_timestamp is Date Time.


6. Formula in Compute Relative
Make sure the "Multiple row formula" is selected
in SAQL, case when previous(CaseId) is null  then "Yes" else "No" end
in the recipe, case when lag(CaseId) IS NULL then 'Yes' else 'No' end


7. format_number() to replace number_to_string()
in SAQL, case when 'OwnerHistory.OwnerChangeCount' is null then "00" else number_to_string('OwnerHistory.OwnerChangeCount',"00") end

in the recipe, case when "OwnerHistory.OwnerChangeCount" IS NULL then '00' else format_number("OwnerHistory.OwnerChangeCount", '00') end


8. Date/time comparison
in SAQL, case when ('CreatedDate_sec_epoch' >= StartDateTime_sec_epoch) && ('CreatedDate_sec_epoch' <= EndDateTime_sec_epoch) then "Yes" else "No" end

in the recipe, case when (to_unix_timestamp(CreatedDate) >= to_unix_timestamp(StartDateTime)) AND (to_unix_timestamp(CreatedDate) <= to_unix_timestamp(EndDateTime)) then 'Yes' else 'No' end


9. substr()
Formula substr() has no change in recipe
case when substr(OwnerId, 1, 3) = '00G' then 'Yes' else 'No' end


10. IN() function
in SAQL, Type in ["Transfer", "TransferredToSbrSkill"]
in the recipe, Type IN ('Transfer', 'TransferredToSbrSkill')
 


Reference:

Sunday, August 11, 2024

Navigating Salesforce's Governor Limits (Part-2)

How to Manage Governor Limits in Salesforce: Key Challenges and Best Practices

This is the continuation of Part 1, a guest blog post by Dorian Sabitov.



Governor Limits are crucial for keeping Salesforce's multi-tenant environment running smoothly and efficiently. However, they can also present significant challenges for developers, especially when building complex applications or scaling existing solutions. Understanding these challenges is key to effective Salesforce development.

Common Challenges with Governor Limits

1. Hitting SOQL Query Limits

One common issue developers face is exceeding the limit on SOQL (Salesforce Object Query Language) queries. This often happens with complex or inefficient queries. When the query limit is surpassed in a single transaction, it triggers a runtime exception and causes the transaction to fail.

Impact: This disruption can interrupt operations, lead to data retrieval issues, and require code refactoring, consuming valuable development time and resources.


2. Exceeding CPU Time Limits

Apex code execution has strict CPU time limits to prevent any single transaction from monopolizing processing power. Exceeding this limit is a frequent challenge, particularly in large-scale or resource-intensive applications.

Impact: Transactions that surpass CPU time limits are terminated, interrupting business processes and degrading user experience. Identifying and optimizing inefficient code is essential but can be time-consuming.


3. DML Operation Limits

Salesforce restricts the number of DML (Data Manipulation Language) statements, such as insert, update, delete, and undelete, within a single transaction. Exceeding this limit causes transaction failures.

Impact: Developers must batch DML operations or use more efficient design patterns to stay within limits, adding complexity to the development process.


4. Heap Size Limits

Heap size refers to the memory allocated to an Apex transaction. Handling large data sets or complex objects can easily exceed the heap size limit.

Impact: Exceeding heap size can lead to memory overflow errors, causing transactions to fail. Developers need to optimize code to manage memory usage effectively.


5. API Call Limits

Salesforce sets daily and concurrent limits on API calls to ensure fair usage among all tenants. Exceeding these limits can halt integrations and disrupt data flow between systems.

Impact: This can affect external system integrations, leading to delays in data synchronization and operational inefficiencies. Monitoring and managing API usage becomes critical, especially in scenarios involving Salesforce SAP integration. Proper planning and optimization strategies are essential to prevent these issues and maintain seamless integration.


6. Email Sending Limits

Salesforce imposes limits on the number of single and mass emails that can be sent. Reaching these limits can be problematic for organizations relying on Salesforce for email communications.

Impact: Hitting email limits can hinder marketing campaigns, customer notifications, and internal communications. Developers need to implement alternative strategies for email delivery when limits are reached.


7. Data and File Storage Limits

Storage limits for both data and files can pose challenges, especially for organizations with large amounts of data or extensive document management needs.

Impact: Exceeding storage limits necessitates data archiving, deletion, or purchasing additional storage, adding costs and operational overhead. Efficient data management strategies are essential to mitigate these issues.


Best Practices for Managing Governor Limits

Effectively managing Governor Limits in Salesforce is essential for ensuring optimal performance and stability. 

1. Optimize SOQL Queries

Efficient queries are crucial for staying within SOQL limits. Consider the following practices:

  • Selective Fields: Query only the necessary fields to minimize resource usage.

  • Indexed Fields: Use indexed fields in WHERE clauses to speed up query execution.

  • Limit and Offset: Handle large data sets incrementally with LIMIT and OFFSET.

  • Avoid Nesting: Minimize nested SOQL queries to reduce complexity and execution time.


2. Implement Batch Processing

Batch processing helps manage large data volumes within limits.

  • Batch Apex: Use Batch Apex to process records in chunks, distributing the workload.

  • Scheduled Apex: Schedule batch jobs during off-peak hours to spread resource usage.


3. Efficient DML Operations

Optimizing DML operations can significantly reduce resource consumption.

  • Bulk Processing: Perform bulk DML operations using collections instead of single-record operations.

  • Prevent Recursive Triggers: Design triggers to avoid recursion and use static variables to control trigger execution.


4. Manage Heap Size

Effective memory management is key to staying within heap size limits.

  • Scoped Variables: Limit the scope of variables to ensure they are garbage collected.

  • Transient Variables: Use transient variables in Visualforce controllers for temporary data.

  • Efficient Structures: Use efficient data structures and algorithms to minimize memory usage.


5. Optimize API Calls

Proper API call management helps avoid exceeding daily and concurrent call limits.

  • Reduce Call Frequency: Cache data locally and batch requests to minimize API calls.

  • Monitor Usage: Regularly monitor API usage and set up alerts for approaching limits.

  • Asynchronous Processing: Use asynchronous methods (Future methods or Queueable Apex) for non-urgent tasks.


6. Efficient Email Practices

Optimizing email sending helps manage Salesforce email limits.

  • Third-Party Services: Use external email services for high-volume needs.

  • Batch Emails: Send mass emails in batches to stay within limits.


7. Effective Storage Management

Managing storage efficiently helps avoid data and file storage limits.

  • Archive Data: Move outdated or less accessed data to external storage.

  • Limit Field Tracking: Track only essential fields to reduce storage consumption.

  • File Compression: Compress large documents and attachments to save space.


Tools for Monitoring and Diagnostics

Salesforce offers various tools to help monitor and diagnose resource usage, making it easier to manage Governor Limits.

  • Debug Logs: Monitor Apex code execution, workflow rules, and other processes to identify inefficiencies.

  • Salesforce Optimizer: Receive recommendations for improving performance and staying within limits.

  • Apex Exception Emails: Configure to get notifications when limits are exceeded for quick resolution.

By following these best practices, developers can effectively manage Governor Limits, ensuring their Salesforce applications are both performant and compliant. Efficient query optimization, batch processing, and smart resource management are key to navigating these constraints. Additionally, it can be beneficial to hire a Salesforce consultant who can provide specialized expertise and guidance, helping you overcome these challenges and optimize your Salesforce environment. Moreover, leveraging Salesforce's monitoring and diagnostic tools enhances the ability to stay within limits and optimize performance.


Wrapping Up

By following these best practices, you can manage Governor Limits effectively and build applications that perform well and scale smoothly:

Write Efficient Code: Efficient coding is key to staying within Governor Limits. This includes such things as optimizing SOQL queries by selecting only necessary fields, using batch processing for handling large data sets, managing memory carefully by limiting the scope of variables, and using efficient data structures.

Monitor and Manage: Regularly monitor and manage API calls and email practices to avoid hitting daily or concurrent limits. Use asynchronous processing methods to spread out the workload and prevent bottlenecks.

Leverage Salesforce Tools: Use Salesforce's tools for monitoring and diagnostics, like Debug Logs and Salesforce Optimizer, to keep an eye on resource usage and spot areas for improvement. Setting up Apex Exception Emails can also alert you when limits are exceeded, so you can act quickly.

Handle Storage Wisely: Avoid hitting data and file storage limits by archiving old data, tracking only essential fields, and compressing files to save space.

Remember, the goal is to deliver a great user experience while staying within Salesforce's resource management guidelines. That’s all my friend! With a good understanding and strategic approach, you can overcome the challenges of Governor Limits and make the most of the Salesforce platform.




Page-level ad