What is the use of transient keyword in Salesforce?

What is the use of transient keyword in Salesforce?

Declaring variables as transient reduces view state size. A common use case for the transient keyword is a field on a Visualforce page that is needed only for the duration of a page request, but should not be part of the page’s view state and would use too many system resources to be recomputed many times during a request.

The transient variables are not passed to view state and therefore not stored in View State.

Check the below link for more info

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_transient.htm

Cheers!!!

Leave a Reply