Salesforce Certified Platform Developer II — Question 277
A Salesforce developer is hired by a multi-national company to build a custom Lightning application that shows employees their employment benefits and earned commissions over time. The application must acknowledge and respect the user's locale context for dates, times, numbers, currency, and currency symbols.
Which approach should the developer implement to ensure the Lightning application complies with the user's locale?
Answer options
- A. Create a Hierarchical custom setting to store user preferences
- B. Use the $Locale value provider to retrieve the user preferences
- C. Use the $User global variable to retrieve the user preferences
- D. Use JavaScript in the component's controllers to format values
Correct answer: C
Explanation
The correct answer is C because the $User global variable contains specific user information, including locale settings, which are essential for formatting dates, times, and currency according to the user's preferences. Option A is incorrect as Hierarchical custom settings do not automatically cater to individual user locales. Option B, while useful, does not provide the same direct access to user-specific preferences as $User. Option D involves JavaScript for formatting, but without the correct locale context, it may not yield accurate results.