Posts

Salesforce Fact #882 | Handling decimal data in LWC returned from apex wrapper

Image
We need to be careful while dealing with large decimal values in LWC returned from apex in wrapper structure. If the value is large, it is converted to String to avoid any loss of precision. Reference:  https://salesforce.stackexchange.com/questions/327214/lwc-autoconverting-decimal-into-string-sf-bug Attached are the screenshots.

Salesforce Fact #881 | Community user check using ContactId on User

Image
We can make use of ContactId field in User object to identify if the current logged in user is a community user or not. The same can be used in LWC. Attached is the screenshot. Note: The ContactId field cannot be updated manually and while trying to do so, the below error is encountered: 'You can't create a contact for this user because the org doesn't have the necessary permissions. Contact Salesforce Customer Support for help.'

Salesforce Fact 880 | Impact on query using user fullname due to user locale change

Locale changes affect the name format of the user. For some of the locales, the Lastname appears followed by Firstname when full name is displayed. So, if we have any logic where we are fetching data based on the Fullname field on User object, we need to be careful.  For example, if the user's full name is 'Tom Stewart' where Firstname is 'Tom' and Lastname is 'Stewart', in case of Hungarian(Hungary) locale this is interpreted as 'Stewart Tom'. So, either we should use any other field like username or we should use any other filter to fetch the required data.

Salesforce Fact #879 | Removing decimals in JS

Image
In order to remove decimals from a number in JS, we can make use of the bitwise not operator. Same can be used in LWC. Attached is an example screenshot.

Salesforce Fact #878 | (already output) error in debug log

Image
Have you encountered the error (already output) in the debug log? This error is encountered whenever the collection is not initialized or reinitialized properly in the code logic and it might lead to unexpected results. Reference:  https://salesforce.stackexchange.com/questions/290468/to-know-more-about-already-output-in-logs Attached is an example screenshot.

Salesforce Fact #877 | Exploring lwc-codemod tool

Image
At times, we face difficulty in debugging syntax issues in HTML file in LWC. The lwc-codemod tool can help on resolving few of the HTML syntax errors. To get this working, once the tool is installed, we need to use the following command: lwc-codemod html-template-cleanup <path> path is the directory where the LWC is located. Reference:  https://github.com/salesforce/lwc-codemod?tab=readme-ov-file Attached are example screenshots.

Salesforce Fact #876 | PICKLISTCOUNT() in FormulaEvalInApex

Image
While using the PICKLISTCOUNT() function in the FormulaEvalInApex feature, it counts the number of semicolons unlike the PICKLISTCOUNT() function in the formula which returns the number of selected values in the multi-select picklist. So, we need to be careful if we use  FormulaEvalInApex  feature with PICKLISTCOUNT(). Ideally the correct result is returned count+1. Attached is the screenshot.