Posts

Showing posts with the label get records

Salesforce Fact #929 | Nth highest in screen flow

Image
We can find the Nth highest value in screen flow using Get Records with a bit of logic. For example, we want to find the Nth highest NumberOfEmployees value across all the accounts. The idea is to fetch the records and then run a check to iterate over the records as long as the temp variable value is less than N value. The temp variable is initialized to 1. In the assignment we would keep on removing the first record. At the end, we will pick the first record from the collection. Attached are the screenshots. Note: this is just a POC flow and the error handlings, best practices are not covered.

Salesforce Fact #913 | Access selected record field values in screen flow lookup w/o Get Records

Image
Suppose we are using the Lookup element in the screen flow and once a record is selected, we would like to get the value from other fields. Now, Lookup provides record Id and record Name field values by default. So in order to get the other field value we need to use a Get Records. But hold on! There is an option to get the field values without using a Get Records element. We need to define a child sobject variable and then in the advanced section, set the parent field Id with the record Id of the selected record in Lookup. In this example, we have a lookup of Account record and we are using a Contact record variable and setting the AccountId field with the selected record Id and later on accessing the field values from account. Attached are the screenshots.

Salesforce Fact #910 | Picklist Contains operator in flow Get Records with translation

Image
Similar to apex, we need to be careful while using Contains operator in flow along with picklist translation. In this example, we have added the french translation for the Account Industry picklist value 'Banking'. Now, while using Contains operator on the Industry picklist in Get Records element, it works fine for English language but does not work for French language. No records are fetched in the Get Records for french user. To resolve this, we need to remove the Contains check from the Get Records and check the same by adding a decision element afterwards. Attached are the screenshots.

Salesforce Fact #787 | UserPermissionAccess

There is an object named UserPermissionAccess which represents the permissions accessibility of the current user. We can use Get Records element on this object in flow to check permissions like 'Activate Contracts' or 'Activate Orders' of the current user. Reference:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_userpermissionaccess.htm

Salesforce Fact #9 | Flow tweak

Image
Suppose we have a use case: we have to update the description of certain account records daily and we are using auto-launched flow for this. Now, we have get records and update records element in auto launched flow which we can use for this scenario. So we may think like we will first fetch the records using a get records element and then we will iterate through each of the account record and populate the description field. And in the end, we will update the data using the same set of record which has been returned from get records element. But here is the tweak, if we have a use case where we are fetching the data in the flow, doing some modification and then have to update the same records, we cannot rely on the get records result set. We have to create one more collection variable and add each record in it once the description is updated. Also we have to use two separate assignment element one for updating the description of the current iterated record and the second ...