Saturday, 31 August 2019

Trigger Framework Salesforce

In ApexHours we did one session on Apex Trigger Framework in Salesforce with ADAM OLSHANSKY. In that session we talk about what is a benefit of using a trigger framework, How many trigger framework are available, which one is lightweight apex trigger framework and Comparison of different approaches.

In that session we talk about all below Trigger Framework
1) Trigger Handler Pattern
2) Trigger Framework using a Virtual Class
3) Trigger Framework using an Interface
4) An architecture framework to handle triggers


Why Trigger Framework ?

 A framework may, however, greatly simplify your development efforts when your code base gets large. In a nutshell, your framework should have the following goals:-
  1. Generic code that can be extended for any object
  2. Ensures triggers are consistently handled and only required code is needed
  3. Allows for simple Triggers and Handlers
  4. Handles routing for you
  5. Enforces consistent trigger behavior
  6. Easily allows for trigger bypasses

Trigger Handler Pattern

Please check this post to learn about Handler pattern and code. Lets talk about what is the advantage of Trigger Handler Patter.
  1. Apex Class that handles trigger logic
  2. Allows code to be called from other code or tests
  3. Uses specific Trigger contexts and Trigger variables for routing
  4. Keep Triggers Simple
  5. Allow for greater flexibility
  6. Make code reusable
  7. Unit tests are much easier


Please check this recording for code walk-through. What is missing in Handler pattern ?
  1. Still duplicated code in every trigger
  2. How can we simplify things?
  3. How can we make our process repeatable?

Trigger Framework using a Virtual Class

 Please check this post to learn more about Virtual Class Trigger Framework.



Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
  •  1 line trigger
  • Only need to add handler methods that we want to use
  • All routing is handled for us



Trigger Framework using an Interface

 Please check this post to learn about this framework.

 Please check this recording for code walk-through. Accomplishments with this Trigger framework :-

  • 1 line trigger
  • All routing is handled for us
  • All handlers are consistent and will have the same methods
  • Multiple ways to deactivate a trigger

An architecture framework to handle triggers

 Please check this post to learn about this framework.



Please check this recording for code walk-through. Accomplishments with this Trigger framework :-
  • 1 line trigger
  • All routing is handled for us
  • Establish all methods while letting us pick and choose which ones we want
  • Individual event handler methods

Please check our YouTube Recording to learn more about all Trigger Framework and Code.
https://www.youtube.com/watch?v=U5ZOA9EY3Kg&t=7s





Here is link for all frameworks:-

Thank

Monday, 19 August 2019

Create Object From Spreadsheet | Excel sheet | Lightning Object Creator


Now Converting excel spreadsheet data into Salesforce Objects is every easy. In Dreamforce 18, Salesforce promised to make app creation easier and faster when they introduced Lightning Object Creator. With the Lightning Object Creator, it only takes a few steps to translate the spreadsheet columns into fields, define field types and import all the spreadsheet data. With Lightning Object Creator, Salesforce is expanding integrations with Google Cloud.

This feature helps user to create mass number of fields (using excel template) of different field types in few clicks.

NOTE: You will be able to see it in your sandbox(es) from August 7 2019 or if you go to this link: object-creator.salesforce.com.

Lets see how it will work :-

Turning spreadsheets into custom objects is as easy as three simple steps.

Step 1) Navigate to  Lightning Object Creator


Click on Setup->Object Manager-> Then Select Custom Object From Spreadsheet.



Step 2) Upload Spreadsheet.


Now upload the spreadsheet from your computer, google sheet or Office 365 or Drive.


After uploading the Excel sheet Salesforce will automatically detect the fields. You can customize the Salesforce field name and field type. Additionally, you can choose to add a particular field to a page layout directly as well like below screen.


You can also view the data preview after click on below selected button

Step 3) Setup Object Properties


You can control of the object’s permissions including enabling chatter for the object, allowing search and reporting.



Some Important Point
  1. By default your excel file tab name will become Object name, we can change the Object name after uploading the file into Salesforce
  2. We can not create formula field, relationship fields and Rollup summary field.


For more detail please check below post

1) https://admin.salesforce.com/lightning-object-creator-now-generally-available
2) https://www.salesforce.com/blog/2018/09/lightning-object-creator-spreadsheets-into-apps.html
3) https://www.salesforce.com/blog/2019/08/upload-spreadsheets-lightning-object-creator.html


Thanks,
Amit Chaudhary
Capture.JPG  @amit_sfdc    @ApexHours
  Salesforce Apex Hours 
     #SalesforceApexHours