Thursday, 27 July 2023

Enhancing Record Processing: Automating Bulk Operation with Salesforce Flow from List Views

Requirement:

In an E-commerce sector project, the client based in Georgia, USA was required to implement bulk operation(To update multiple records simultaneously) from a list view button using salesforce flow.

Challenge:

As we do not have to use the apex class for this requirement, our main challenge was passing all the selected record Ids from the sObject's list view to the salesforce flow.

Solution:


Concisely, To achieve this follow the below steps:
  • Creating a screen flow with a variable named "ids" for delete operation.
  • Creating a List button with a custom URL.

 

  • To Create Screen Flow:
  • Go to the setupQuick Find search box ⇒ Flows.  
  • After that click on New Flow and then select Screen Flow.
  • To create a collection variable go to the toolbox and click on New Resource button.
  • Select Variable as Record Type and Enter values as in below image.

 

  

[Note: API Name of the variable must be "ids".] 

  •  After that create a variable for record count to assign the count of the ids. 

 

 

  •  Add Decision Element and enter values as below.

 


  •  Add Delete Record element for Available outcome and add Screen element for Not Available outcome to display Error message. 

 

 

  • After Delete Record element add Screen element for success message.
  • Have a look on below image for flow reference.

 

 

  • To create a List Button with a custom URL:
  • Go to the Object Manager and open sObject(here it is Account) then click on "Buttons, Links and Actions" Tab.
  • Then click on "Create Button or Link" button and enter values as below in image and click on save button.

 

 

  • Here the custom URL "/flow/Delete_bulk_records?retURL=001/o" includes API Name of flow i.e. Delete_bulk_records and retURL=001/o to return to the Accounts List View page.
  • The value of retURL 001/o includes "001" is from first three character of record Id of Account sObject and "o" to redirect to the list view page.
  • After creating List Button click on List View Button Layout to add the List Button in List View Layout.
  • Edit the List view Layout, Scrolldown the cursor to the Custom Button and Add the created List Button in the Selected button list and save the changes. 

 

Output: 

 


Conclusion:

This is how the Automating Bulk Operation with Salesforce Flow from List Views is implemented which allows you to update multiple records simultaneously, saving time and effort.

  

If you have any questions you can reach out our Salesforce Consulting team here.

Thursday, 20 July 2023

Salesforce's New Assert Class


Introduction To The New Assert Class

  • The Assert class is designed to provide clearer assertions within Apex test code and make it easier for developers to write more maintainable test code.
  • This new class offers multiple static methods and is intended to be a dedicated location for assert methods.
  • The addition of this class means that developers will have all the assert methods they need in one place.
  • Starting with “Assert” is more intentional and readable, making the test code cleaner.
  • Although Apex still allows the use of System assert methods.


Code Example of New Assert Class

  • The above code demonstrates the use of Old and new Equality assertions and Expression true Assertion. 
  • As in the code, we are using the same system assert method for Equality and Expression true assertion using different statements while the new Assert class provides two different methods for Equality and Expression true assertion which makes the code more intentional.


  • The above code represents the use of Not null and Instance of type assertions where the use of these two assertions makes the code more readable. 
  • There are two other assertion methods in the new assert class such as Assert.isNull(value, msg), Assert.isNotInstanceOfType(instance, System.notExpectedType, msg). 
  • If you noticed, like old assertion methods, the new Assertion methods also include an assertion message. 

  • The above test class method includes the Error Testing Assertions where the same assert method is used for error testing in the old assertion way but the new assert class provides the specific method. 


Conclusion

The new assert class provides an improved and more efficient way to write assertions, resulting in better testing and higher code quality.



If you have any questions you can reach out our Salesforce Consulting team here.