Posts

Showing posts from December, 2022

Salesforce Fact #595 | SystemModStamp field

There is a standard field SystemModStamp which is present in all objects. It is similar to LastModifiedDate field but the difference is, LastModifiedDate is the date and time when the record was last modified by the user whereas SytstemModStamp is the date and time when the record was last modified by a user or a standard automated process. Reference:  https://help.salesforce.com/s/articleView?id=000387261&type=1

Salesforce Fact #594 | LWC: pass value from parent to child conditionally

Image
Suppose we have a scenario in LWC where we want to pass an attribute value from parent to child component only when it has some value in parent. If it is null, it will keep the immediate previous value in child. We can implement the same using some condition check. In this example, we have an input in parent component and the same value is passed to child. But if it is blank, that value is not passed to child and the immediate previous one is kept. Attached are the screenshots.

Salesforce Fact #593 | Custom SendEmail global action using LWC

We can create custom quick action in LWC for the SendEmail Global action and set subject, body etc. values. Reference: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_quick_actions_email Note: If namespace is enabled in the org, the apiName of the quickAction would be of the format 'Global.<namespace>__SendEmail', else it would be 'Global.SendEmail'.

Salesforce Fact #592 | Assign Leads to territories

Now Leads can also be assigned to territories. To enable the setting, go to Setup -> Territory Settings -> select the checkbox 'Enable Leads'. Once the setting is enabled, the corresponding access level can be chosen. The Assigned territories related list gets available to be added in the Lead page layout. The territory assignments are tracked in same ObjectTerritory2Association object. Reference:  https://help.salesforce.com/s/articleView?id=sf.tm2_assign_territories_manually.htm&type=5    

Salesforce Fact #591 | Updating custom Geolocation fields from LWC

Image
Similar to retrieving, we can also update custom Geolocation fields from LWC. We need to refer the latitude and longitude value separately suffixed with '__s' since it is a compound field. In this example, we are updating a Geolocation field on Account taking the input from LWC. Attached are the screenshots.

Salesforce Fact #590 | SOQL semi-join & anti-join

What are semi-join and anti-join in SOQL? A semi-join is a subquery on another object in an IN clause to restrict the records returned. example: SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Opportunity WHERE IsClosed=true) An anti-join is a subquery on another object in an NOT IN clause to restrict the records returned. example: SELECT Id, Name FROM Account WHERE Id NOT IN (SELECT AccountId FROM Opportunity WHERE IsClosed=true) Reference:  https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_comparisonoperators.htm

Salesforce Fact #589 | Access PersonAccount field in LWC

Image
In order to access Person Account fields, the import statement won't work in LWC for Account. We need to specify it the other way as a constant. Attached is the screenshot.

Salesforce Fact #588 | Capitalize each word in apex

Image
We can capitalize every word in the sentence using a bit of apex logic. Here is of one of the approaches.

Salesforce Fact #587 | Pass comma in LWC targetConfig datasource

Image
Similar to passing &, if we need to pass comma(,) in LWC targetConfig datasource as part of text, we need to escape it as '&#8218;'. Attached are the screenshots.  

Salesforce Fact #586 | Pass & in LWC targetConfig datasource

Image
If we try to pass & in LWC targetConfig datasource, we encounter error. So in order to pass the exact value, we need to escape it as '&amp;'. Attached are the screenshots.

Salesforce Fact #585 | Passing slds text style from app builder to LWC

Image
Suppose we have a scenario we want to configure the text style. We can create a LWC with targetConfig property with the slds text style values. Attached are the screenshots. Note: In case of datasource, if we don't use the default attribute the first value provided becomes the default one. If we don't want to set any default value we need to use default="".

Salesforce Fact #584 | Individual object

The Individual object is a standard object in Salesforce org and it is used for the purpose of storing data privacy details. To enable Individual object, go to Setup -> Data Protection and Privacy -> Select the checkbox 'Make data protection details available in records'. Once enabled, the Individual lookup field can be added in the Lead and Contact object page layouts. If we deselect the above checkbox, the Individual object gets disabled. On checking it again, the records can be accessed again. Note: An Individual record cannot be deleted if it is associated with a contact or lead.

Salesforce Fact #583 | Returning true/false from CASE()

Image
CASE functions can't return TRUE or FALSE directly in validation rule. We need to update our condition check to include 0 or 1 or some string. Attached are the screenshots.

Salesforce Fact #582 | Pass selected records from lwc datatable to apex

Image
We can pass selected records from LWC datatable to apex using imperative apex on click of a button. Attached are the screenshots.

Salesforce Fact #581 | LWC datatable validation on row selection

Image
Suppose we have a scenario where we have a lightning datatable in lwc with couple of columns. Now, if the user selects any record where any of the column value is not present, an error message needs to be shown. We can implement this with some JS logic. In this example, the datatable shows contact fields and if any of the Phone or Email is empty of the selected records, it shows an error message. Attached are the screenshots.

Salesforce Fact #580 | Check issandbox in validation rule and formula

Image
There is a field IsSandbox on Organization object which denotes whether the current org is a sandbox or not. But this field is not accessible using the $Organization global variable in formula field and validation rules. So, in order to check issandbox, we can create a custom metadata with a checkbox field and set it to true for sandboxes and keep it unchecked for non-sandbox orgs. Then we can refer this record in formula field and validation rules. Attached are the screenshots.

Salesforce Fact #579 | Pass date value in custom link based on condition

Image
We can pass input parameter value from custom button link based on some condition as well. In this example, we are passing a date value from an account custom button link to a screen flow based on some condition check on the account created date. Attached is the screenshot.

Salesforce Fact #578 | putAll() method in map

Image
There is a method named putAll() in Map Class in Apex. It has two variations. Suppose, we already have a number of sobject records in the map. Now if we want to add further sobject records from the another list of records, we can use the putAll() method instead of iterating over the sobject list. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm#apex_System_Map_putAll Attached is the screenshot.

Salesforce Fact #577 | apex:outputText formatting

Image
apex:outputText supports value formatting using apex:param tag. Reference:   https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm Attached is the screenshot. Note: the <apex:outputText> component doesn't respect the View Encrypted Data Permission for users. To prevent showing sensitive information to unauthorized users, use the <apex:outputField> tag instead.

Salesforce Fact #576 | Access getter in LWC JS file

Image
The getters can be accessed in JS file like the way we can access in HTML file in LWC. If we refer the api property as this.<property name> in JS file it will call the getter function. Attached is the screenshot.

Salesforce Fact #575 | Form factor

Once a component is in use on a Lightning page, you can only increase the supported form factors for the component, not decrease them. Reference:  https://developer.salesforce.com/docs/component-library/documentation/en/lwc/use_config_form_factors

Salesforce Fact #574 | Bullet point in toast message

Image
We can show bullet point in LWC toast message using the corresponding unicode character. Attached are the screenshots.

Salesforce Fact #573 | Account hierarchy columns

How can we configure the hierarchy columns for the Account hierarchy. From Setup -> Object Manager -> Account -> Hierarchy Columns -> New and we can select the fields to be shown. We can select maximum 15 fields. By default the columns are same as the 'Recently Viewed Accounts' list view. Once new column sequence is added, a new list view named 'Org_Account_Hierarchy' appears. Reference:  https://help.salesforce.com/s/articleView?id=sf.account_hierarchy_setup_lex.htm&type=5

Salesforce Fact #572 | Custom object deployment status

We can set the deployment status for custom objects to: In Development, Deployed. When the deployment status is In Development, Only users with the Customize Application permission can see the object tab, search results, related lists, and report data types. It gets available to all users when the status is changed to Deployed. We can also move it back to In Development status in case we are working on enhancement on that object. Reference:  https://help.salesforce.com/s/articleView?id=sf.deploying_custom_objects.htm&type=5