Posts

Showing posts from July, 2021

Salesforce Fact #144 | Assign permission set using screen flow

Image
We can create a screen flow to assign permission set to user. We can use lookup and picklist elements to select the user and permission set and we can create records of PermissionSetAssignment object. In this example, I have created a similar screen flow which checks whether the selected user is already assigned the permission set, if not he/she is assigned the selected permission set. For any other error, an error message will be displayed. Attached are the screenshots.  

Salesforce Fact #143 | Get VF page data in JS

Image
We can get the value of input from the VF page in the JS function. These are two of the approaches. Attached is the screenshot.    

Salesforce Fact #142 | if:true/if:false in base lightning tag

Image
We can add the if:true/if:false condition in the base lightning tag itself in LWC, without creating an extra template tag. Attached is the screenshot .

Salesforce Fact #141 | Pass entire record to flow using recordId

Image
We can pass the recordId in flow by defining a variable 'recordId' of text type and marking it as available for input. But we can also pass the entire record if we define the recordId variable as a record variable. Collected from: Salesforce Flow course on Udemy by Debasish Jena Attached are the screenshots.

Salesforce Fact #140 | Scheduled apex count

We can get the count of apex scheduled jobs in the org. The job type '7' specifies apex scheduled jobs. Below is the query: SELECT COUNT() FROM CronTrigger WHERE CronJobDetail.JobType = '7' Collected from:  https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_monitoring

Salesforce Fact #139 | Lightning flow custom iteration

Image
We can use loop in lightning flow for our custom iteration also, it does not need to be a collection variable all the time. We can use a counter variable and check its value in a decision element and based on that we can repeat a certain assignment/step for a particular number of times. In this example, I am checking the counter value and adding an account record to the list until the counter reaches 10. Attached are the screenshots.

Salesforce Fact #138 | Using VALUE()

VALUE() function is used to convert a text value to number in Salesforce formula.  A general use case is, We have stored a number in custom label and it is getting used in flow. Now in the flow we have to convert it to number before doing any numeric operation. Collected from:  https://help.salesforce.com/articleView?id=sf.customize_functions_i_z.htm&type=5

Salesforce Fact #137 | LWC pass value from parent to child on button click

Image
Suppose we have a use case in LWC where we need to pass value from parent to child only on button click. So, we have a text box where the user will give the input, and the value should not be passed until the button is pressed. This scenario can be implemented by conditionally rendering the child component. Collected from: https://salesforce.stackexchange.com/questions/299066/call-child-lwc-from-parent-lwc-through-button Attached are the screenshots.  

Salesforce Fact #136 | Custom permission check in flow

Image
In lighting flow, we can check whether the current logged in user has a particular custom permission enabled in his/her profile. So this basically returns a boolean value i.e. true/false. But we can also store the result in a text variable and the result is true/false in string. Attached are the screenshots.

Salesforce Fact #135 | Multiselect picklist in screen flow

Image
While working with multiselect picklist in screen flow, if the choice length is greater than 1 then the choices are separated by semicolon as well as with an extra space. Now after the record is created, the extra space is not visible anymore. But we are not required to do any kind of modification to remove the extra space. Salesforce automatically removes it and creates the record with the selected picklist values. Attached are the screenshots.

Salesforce Fact #134 | Screen flow dynamic label

Image
We can use field label dynamically in the screen flow. However, the field api names cannot be set as dynamic value. Suppose we have a use case where we have a picklist with phone and mobile choices. Now based on the selection made by the user, we would show the label of the input phone field. So we can set the same dynamically. Note: a better use case is showing the input phone field in the same screen based on the selection. But the selection value is not available in the same screen. Attached are the screenshots.

Salesforce Fact #133 | Scheduled flow conditional run

Image
Suppose we have a use case where we have configured a scheduled flow which is supposed to run at a particular time every Monday, Wednesday & Friday. We can implement this using custom label and subflow. We can develop a subflow which will return the day of week corresponding to the current date. And we can store the days of the week on which we want the job to run in a custom label and this would be configurable. Now in the flow, we can call the subflow and check whether the current day is the correct one to run the job and then proceed accordingly. Attached are the screenshots.

Salesforce Fact #132 | Validation in screen flow

Image
We can include input field validation in screen flow. But we specify the condition for which the error will be bypassed. In this example, we have a number input field and we expect to receive a number greater than 0, so the condition is inputNumber > 0. Attached are the screenshots.

Salesforce Fact #131 | Max Related Contact count in flow

Image
Suppose we have a scenario where we need to get the count of maximum number of related contacts under an account inside flow. We can use the flow get records element. But we can also use an apex action to get the result. Attached are the screenshots.

Salesforce Fact #130 | Lastmodifieddate unchanged in test class

Image
We can use Test.setCreatedDate() method in the test class to set the createddate of the record as per our need. But it does not change the lastmodifieddate. Attached are the screenshots.

Salesforce Fact #129 | Disconnect authenticator

Image
If we have the salesforce authenticator enabled for the user account, every time we login, the prompt appears to approve the login request from the authenticator app. It is quite disturbing sometimes. We can disconnect the authenticator app from the user record.  Collected from: https://help.salesforce.com/articleView?id=sf.disconnect_salesforce_authenticator_v2_or_later.htm&type=5 Attached is the screenshot.  

Salesforce Fact #128 | Dynamic Lookup in screen flow

Image
Same like dynamic picklist, we can also create dynamic lookup based on the selection made by the user in flow. We can use the set component visibility option. In this example, when the user selects Account he can lookup by AccountId and when he selects Contact he can lookup by Contact. For the ObjectApiName, I have considered Case. Attached are the screenshots.