Weekly Digest of #Apextips- Week 1
Hello Folks,
In this blog, we are going to learn 5 Apextips which developers must now.
So are you guys ready to dive deeper?
Lets go- π
Apextip 1 : Invocable Method
It will run method1 only and not method2 if you call this class from process builder or trigger.
--------------------------------------------------------------------------------------------------------------------------
Apextip 2 : DML exception Database.SaveResults Method
Lets Understand DML exception Tip-
Case: To add multiple records, if single insert is failed then all records insertion is failed.
Solution: Database.SaveResults[] method is used to insert all correct records without exception.π
Checkout below image π€
--------------------------------------------------------------------------------------------------------------------------
Apextip 3 : DML exception Failed record Insertion
Lets learn thisπ
Use Case: I want to use database.result method but if exception occurs then operation should be failed .
Solution : Set the value of database.insert to true. If exception occurs, no record is inserted.π€
Checkout below image π€
--------------------------------------------------------------------------------------------------------------------------
Apextip 4 : issuccess() & getid() methods
Lets understand this tipπ
Usecase: I want to get the Id of inserted account
Solution: Use issuccess() & getid() methods to get record Idπ
issuccess() - Identifies the record created successfully
getid() - To get the record Id
Checkout below image π€
--------------------------------------------------------------------------------------------------------------------------
Apextip 5 :Extract ID of Deleted Account
Lest understand the last tip of this blogπ
Usecase: I want to extract the Id of deleted account
Solution: Use database.delete method to delete accs without exception π
Solution: Use database.delete method to delete accs without exception π
issuccess()- to check status of delete!
getid()-Gets the Id of deleted record
--------------------------------------------------------------------------------------------------------------------------
Hope you guys had learn something new from this Blog. To learn more Apex tips, Stay tuned with us. We post weekly blog of 5 #Apextips.
Feel free to reach us on below contact details.
Thank You
Thank You
Happy Coding!π
Contact:
Twitter Handle : Lakhan Meghani
Apextips Twitter handle : Apextips
linkedin : Lakhan Meghani
No comments:
Post a Comment