Posts

Showing posts from June, 2022

Salesforce Fact #452 | CampaignMemberRecordTypeId

Image
Do you know there is a field CampaignMemberRecordTypeId on the Campaign object which keeps track of the record type Id of the related Campaign member records. This is basically the Id of the record types present in Campaign Member object. Interesting point is, the recordtypeId field is not writeable on Campaign Member object. It takes into consideration the default record type selected while creating the new records. It seems this is to ensure all the campaign members have the same record type and  CampaignMemberRecordTypeId  holds the same record type Id. Attached is the screenshot.

Salesforce Fact #451 | Custom object truncate

Do you know there is an option to truncate custom objects in Salesforce. This is very helpful while removing all the records from a custom object without changing the definition of the object. To enable the feature, In classic experience go to Setup -> Search for User Interface in the quick search -> select the checkbox beside the option 'Enable Custom Object Truncate'. -> Save. Using the truncate option, the records are permanently deleted from the org bypassing the recycle bin. Note: This feature is available only in Classic experience. For more details, check out this Trailhead module:  trailhead.salesforce.com/content/learn/modules/large-data-volumes/perform-data-deletes-and-extracts?trailmix_creator_id=strailhead&trailmix_slug=prepare-for-your-salesforce-sales-cloud-consultant-credential

Salesforce Fact #450 | LastViewedDate in Salesforce

Do you know there is a field named LastViewedDate in each SObject in Salesforce. This field is updated whenever we use the clause FOR VIEW in the SOQL. For example, the below query fetches one account record and updates the LastViewedDate field of the record with the current date time. SELECT Id, Name FROM Account LIMIT 1 FOR VIEW; It also adds or updates a record in an object called RecentlyViewed. For more info, please check  https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_for_view.htm

Salesforce Fact #449 | Simplified validation rule on picklist field value

Suppose we have a validation rule which restricts the account record save when the Account type is any of these values, Prospect and Other. Now, as per the usual approach this is how we would write the validation rule: OR( ISPICKVAL(TYPE, 'Prospect'), ISPICKVAL(TYPE, 'Other') ) But do you know we can simplify the validation rule using CONTAINS() function like this: CONTAINS('Prospect:Other', TEXT(Type))

Salesforce Fact #448 | Auto save chatter post draft

Do you know in lightning experience, a draft of the chatter post is auto-saved every 7 seconds. To get this functionality working, the user's profile should have the 'Edit my own posts' system permission enabled and also the 'Auto draft posts' option must be enabled in chatter settings.

Salesforce Fact #447 | PicklistValueInfo in screen flow

Image
In Screen flow, if we are using record variable and the fields feature, then if a picklist field is having translation added in the translation workbench that translated value corresponding to the current user language is not shown in the UI. To get the translated value, we can make use of the PicklistObjectInfo object. There is a field called DurableId which accepts the input string as <ObjectApiName>.<PicklistFieldApiName>.<PicklistvalueApiname>. We can use a Get Records element to get the translated value to show it in the UI. In this example, we are using an Account record variable with the Type picklist field. The current user language is Spanish and the translation is added for the value 'Prospect'. Using PicklistValueInfo, we are able to get the translated picklist value. Attached are the screenshots.

Salesforce Fact #446 | MutingPermissionSet

Like Permission and PermissionSetGroup, we have one Sobject called MutingPermissionSet which keeps track of all the muting permission sets in the org. We can query this object to get the details: SELECT Id, IsDeleted, DeveloperName, Language, MasterLabel, CreatedDate FROM MutingPermissionSet For more details, check out:  https://developer.salesforce.com/docs/atlas.en-us.234.0.object_reference.meta/object_reference/sforce_api_objects_mutingpermissionset.htm

Salesforce Fact #445 | Pass data from VF page to screen flow

Image
Suppose we have a use case where we are invoking a screen flow from a VF page and we would like to set the value of one of the flow variable from the VF page. The VF page has been exposed as a detail page button. In order to do this, we create a variable in the flow specifying it both as: Available for input and Available for output. Now, in the apex controller associated with the VF page we take a reference of that screen flow and set the value of the flow variable using map. Attached are the screenshots.

Salesforce Fact #444 | Check record access in same SOQL

There is an object named UserRecordAccess using which we can get to know whether a particular user has specific access to one or more records. But do you know we can get that details while querying the actual object itself, no need to query the UserRecordAccess object separately. For example, The below query on Account will return whether the current user has Edit access to the queried records or not: SELECT Id, UserRecordAccess.HasEditAccess FROM Account. Another cool thing is we can also get to know whether the user has access to related record as well. For example, The below query checks whether the current user has read access to the related account records while querying the contact records: SELECT Id, Account.UserRecordAccess.HasReadAccess FROM Contact WHERE AccountId!=NULL

Salesforce Fact #443 | Separate loading of related lists

One of the performance tuning option for related list is to enable the setting pertaining to separate loading of related lists in the record detail pages. If this setting is enabled, the top half of the page gets loaded first and then the bottom half of the page loads since it takes some time to load. To enable the setting, go to Setup -> User Interface -> select the checkbox beside 'Enable  Loading of Related Lists' -> Save. Note: This applies only to classic. For more performance tuning options of related list, check out  https://help.salesforce.com/s/articleView?id=000329931&type=1

Salesforce Fact #442 | Another awesome feature of record-triggered flow

Image
Most of the time we execute some custom logic when there is any change in the value of specific fields of the record. But what if we need to detect if there is any change in the record i.e. there is a change in any of field (excluding audit fields and formula fields obviously!). Salesforce record-triggered flow has this awesome feature where we can compare the previous and current state of the record, without specifying any field explicitly. In this example, we have set up a record-triggered flow on Account and it checks if there is any change in any of the field value and if it is, then it updates the description with some text. Attached are the screenshots. Now, once the record is created, updating no field. Now, updating Account Source.

Salesforce Fact #441 | Adding case team member using Apex

Image
We can assign predefined case teams during case creation which we define in the Case assignment rule. But do you know we can add case team members or even a predefined case team using apex as well. We have two objects related to Case Teams i.e. CaseTeamMember and CaseTeamTemplateRecord which we can use to add individual case team members or add a predefined case team to a Case. To add individual user in the case team, we can specify the parentId, MemberId and the TeamRoleId in the CaseTeamMember, while using CaseTeamTemplateRecord we specify only the ParentId and TeamTemplateId which adds the predefined case team to the case which in turn adds the members who are present in the predefined case team. Attached is the screenshot.

Salesforce Fact #440 | Relative date filter in dynamic related list

Image
So, we now have the dynamic related list as GA. Suppose, we have a use case to show related contacts on the account detail page which are created in last 5 days. We can add the condition using relative date option i.e. LAST 5 DAYS. Attached is the screenshot.

Salesforce Fact #439 | Create Report screen enhancements

Image
So, we have got a couple of enhancements in the Create Report screen. Here are those: 1. Now we have the option to hide a particular report type. Once hidden, they appear under a category named 'Hidden Report Types'. We can again make the report type visible from here.   2. Now we can directly navigate to the Report Type setup page using the button: Manage in Setup. 3. Also we can check the details of the report type like created date, created by, associated objects etc. from this Create Report screen. 4. Also we can quick search for any field present in the report type.

Salesforce Fact #438 | Report chart in LWC

While using Chartjs in LWC, use the version 2.7.3 as the static resource because the latest version is not compatible with LWC locker service. Also, for creating report chart refer to this awesome article:  https://medium.com/@ishaarora_49656/add-dynamic-data-to-chart-in-lwc-9d88e8b4516e

Salesforce Fact #437 | Importing campaign member statuses

Image
We can add new campaign member statuses using data import as well. For this, we use the CampaignMemberStatus object and refer the Label field to populate the new status value. We can also set the IsDefault or HasResponded flags if needed. Attached are the screenshots.

Salesforce Fact #436 | Updating campaign member association

Image
Once we create a CampaignMember with a lead or contact, the association cannot be updated. Attached are the screenshots.

Salesforce Fact #435 | Adding both lead and contact as campaign members

Image
To add any member to a Campaign from the UI, we can select either select a Lead or a Contact at a time. But do you know, using data load we can add a Lead and a Contact under the same campaign at the same time. Attached are the screenshots.

Salesforce Fact #434 | Duplicate Campaign member error

Image
We cannot add same Lead/Contact twice as a member in the same campaign. Attempting to do so, will create the error: 'Attempted to add an entity to a campaign more than once'. Attached are the screenshots.

Salesforce Fact #433 | CampaignMemberStatus

Image
Do you know there is an object, CampaignMemberStatus which keeps track of all the Campaign member statuses for a particular campaign. Some of the fields are: 1) SortOrder: It is the order in which the member status picklist values are displayed while adding a contact or Lead to a campaign. 2) HasResponded: It is true if the member status is marked as responded. 3) IsDefault: We can have only one member status as default at a time. This flag indicates whether the value is default or not. This is basically the default member status while adding any member to the campaign. For more details, check  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_campaignmemberstatus.htm Attached are the screenshots.

Salesforce Fact #432 | Restrict API name change of picklist values

Do you know we can restrict the editing the API names of picklist values. To enable this setting, go to Setup --> Picklist Settings --> Disable the setting 'Allow editing of API names of picklist values'.

Salesforce Fact #431 | Pass list of string from screen flow to LWC

Image
Do you know we can pass list of String from screen flow to LWC. For this, we need to define a targetConfig property of type String[] in the meta file of LWC. Attached are the screenshots.

Salesforce Fact #430 | Aggregate query using Database.query()

Image
We can use Database.query() method to get Aggregate query result as well. We can use alias if we want. Attached is the screenshot.