Posts

Showing posts from June, 2023

Salesforce Fact #706 | Optional description attribute in lwc combobox option

Image
We can use one optional attribute 'description' for each option in lightning-combobox. The descriptive text displays below the option label and can be helpful to the user. Reference:  https://developer.salesforce.com/docs/component-library/bundle/lightning-combobox/documentation Attached are the screenshots.

Salesforce Fact #705 | Disabling few picklist values in LWC

Image
Suppose we need to make some of the picklist values as disabled in LWC. Now, the individual options of lightning-combobox doesn't support any disabled attribute. So, we can implement the same using slds and iteration logic. In this example, we have 3 options and option2 is disabled. Attached are the screenshots.

Salesforce Fact #704 | Sobject picklist dependency in LWC

Image
We can show the picklist dependency of SObject fields in LWC. Reference:  https://sfdclearners.co.in/2020/05/23/dependent-picklist-in-lwc/ Attached are the screenshots.

Salesforce Fact #703 | POC on adding a user to multiple territories using screen flow

Image
UserTerritory2Association object keeps track of the user assignment to the territories. Let's have an automation leveraging screen flow to let admins add a user to multiple territories in a single go. In this example, we have created a screen flow which takes the userid input and also allows the user to select multiple territories(in this case, it is max 5). Then, we are checking whether the user is already part of the territory, if not we are creating UserTerritory2Association records which eventually adds the user to the selected territories. Note: Since Territory2 object is not supported in UI API, we get an error on selecting the territory but it can be ignored. Attached are the screenshots.

Salesforce Fact #702 | Control over task assignment notification

Image
There is an Activity Setting 'Enable User Control over Task Assignment Notifications'. If it is enabled, A section named 'Email Settings' appears in the User Settings page under Activity Reminders. With this option, the user can opt in to receive task assignment notifications. Reference:  https://help.salesforce.com/s/articleView?id=sf.tasks_enable_task_email_notifications.htm&type=5 Attached are the screenshots.

Salesforce Fact #701 | Access custom label dynamically in apex

Image
We can now access custom labels in apex dynamically. With Summer'23 release, we have a new System.Label.get() method which returns the translation of a particular custom label for a particular language. Reference:  https://help.salesforce.com/s/articleView?id=release-notes.rn_apex_system_label_methods.htm&release=244&type=5 Note: passing the namespace as blank also returned the same results. Attached are the screenshots.

Salesforce Fact #700 | lwc:spread in action

Image
Now we can spread properties in child LWC component after it is passed from parent component. Thanks to Summer'23 release. With lwc:spread directive, we can pass the entire object's properties as key,value pair to child component instead of passing individual attributes and in the child component we can create public properties for individual attribute and access the data. Note: This does not work yet for nested object structure. Reference:  https://help.salesforce.com/s/articleView?id=release-notes.rn_lwc_directives.htm&release=244&type=5 Attached are the screenshots.

Salesforce Fact #699 | Get current app details

How can we get the current app name in apex? we can query UserAppInfo and AppDefinition objects to get the details. The below SOQLs are used to get the details: UserAppInfo userAppInfo = [SELECT Id, AppDefinitionId FROM UserAppInfo WHERE UserId = :UserInfo.getUserId()  ORDER BY LastModifiedDate DESC LIMIT 1]; AppDefinition appDefinition = [SELECT DurableId, Label FROM AppDefinition Where DurableId = :userAppInfo.AppDefinitionId LIMIT 1]; Reference:  https://developer.salesforce.com/forums/?id=9062I000000IDhRQAW

Salesforce Fact #698 | Aggregate functions in graphql

Image
We can use aggregate functions as well with graphql wire adapter.  In this example, we are getting the related Contact and Opportunity count for an account using the ' totalCount ' variable. Reference:  https://developer.salesforce.com/docs/platform/graphql/guide/aggregate-examples.html Attached is the screenshot.

Salesforce Fact #697 | Getting related contacts using graphql

Image
How do you pass dynamic value for the parameter in graphql query. The values need to be passed in the ' variables ' parameter and the return value is accessed through a getter function. In this example, we are getting the related contacts passing the accountId from the account record detail page. Reference:  https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_graphql Attached is the screenshot.

Salesforce Fact #696 | GraphQL wire adapter in LWC

Image
With Summer'23 release, the GraphQL wire adapter can be used in LWC and it makes use of LDS. In this example, we are fetching the account records with non-empty Rating and Type value. Note: The result contains 10 records. Reference:  https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_graphql Attached are the screenshots.

Salesforce Fact #695 | getFieldDisplayValue in LWC

Image
How do you access localized values for field values of record in LWC? We can use the getFieldDisplayValue module for the same. In this example, we have added french translations for the Account Rating picklist field and we are getting the localized value based on user's language using  getFieldDisplayValue. Reference:  https://developer.salesforce.com/docs/component-library/documentation/en/lwc/reference_get_field_display_value Attached are the screenshots.

Salesforce Fact #694 | Reactive screen components(beta)

Image
With Summer'23 release, we now have the reactive screen components(beta) feature. Although there are certain limitations currently, but this will definitely be a game changer. To enable this feature, go to Setup -> Process Automation Settings -> Enable the checkbox 'Opt in to Reactive Screen Beta'. In this example, we have an input text field in screen flow and we are setting the value of the slider component with the length of entered data. Reference:  https://admin.salesforce.com/blog/2023/flow-reactive-screen-components-beta-learn-moar-summer-23?icid=TH:th-trailmix:learn_moar_summer_23 Attached are the screenshots.

Salesforce Fact #693 | User access policy in action

Image
User Access Policies is now in Beta phase. Thanks to Summer'23 release. Now, you can automate the Permission Set, Public Group or queue assignments once you create or update the any user which matches a particular Profile/Role/Permission Set condition. In this example, we have setup a User access policy which assigns the PS 'Test Permission Set' and Public group 'Test PG1' if the user with profile 'Test Profile' is created/updated. Note: There are couple of statuses available while configuring User access policy. It gets executed only if it is in 'Active' status.  In order to enable the feature, go to User Management Settings -> Enable 'User Access Policies (Beta)'. Attached are the screenshots.

Salesforce Fact #692 | Update case owner with only read access

Is it possible for a user to have only READ access on a case record, but he is still able to change the owner of the record. There is an app permission called 'Transfer Cases' which enables a user to change case owner with read only access on the case. Profile/PS -> App Permissions -> Under Call Center section, enable Transfer Cases.

Salesforce Fact #691 | Bind variable with date literals in SOQL

Image
Bind variables cannot be used in SOQL with date literals like 'LAST_N_DAYS' in static context. So as a workaround, we can calculate the date value and then use the same in the SOQL. Reference:  https://salesforce.stackexchange.com/questions/7515/using-soql-apex-bind-variables-for-date-literals-e-g-last-n-days-today-this Attached is the screenshot.