1

I came across a (nearly) 5 year old question today that was closed as "Off Topic"; I was surprised because the question was the exact question I had come to research, and the discussion in the answers covered a number of points I was considering.

The question itself asked about "best practices" for performing an activity (saving user preferences) in a Lightning Component. LCs are certainly on-topic, and I feel like "best practices" should be as well; Salesforce as a platform has many best practices that provide the best user experience when followed, and I believe this site should promote those.

The Closed notice also included a comment which I'm guessing was tied to the close-vote reasons:

Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it....

This question had no code, because it was not a "code" question. OP did mention a few options they had considered. Two answers were given before the question was closed; one presented an option I hadn't thought of (local storage), and the other presented several other options along with pros and cons. I found it all to be useful and on-topic, and I'm struggling to see why it was closed. I have the rep to edit-and-reopen, but I wanted to seek some other opinions on this to make sure I'm not missing something.

2
  • Yeah I dunno, doesn't seem off topic to me. That said, I think the core question was missed, namely if JSON is really the appropriate format to store these settings. But if using local storage, it's probably necessary.
    – Adrian Larson Mod
    Commented Apr 19 at 16:29
  • 1
    @AdrianLarson My answer tried to imply JSON wasn't the right format, but you're right, it could use some cleaning up.
    – sfdcfox Mod
    Commented Apr 21 at 12:44

1 Answer 1

1

The question is fine, although I feel both answers could use some editing. localStorage is fine for an app that runs on one device, but most people use more than one, and there's no way to sync localStorage across all devices. My answer also could use some work, as it tries to express that JSON is a bad idea for memory-constrained storage like Custom Settings, Custom Metadata, and localStorage, but clearly misses the mark.

The close reason is definitely incorrect. At best, I would have chosen a close reason of opinion-based, as salesforce.com doesn't really have a "best practice" regarding storing settings, though storing JSON would likely be considered an anti-pattern. That said, I did take the time to answer the question, which I only do if I think the question is important enough to solve a common problem.

Definitely feel free to reopen the question. I would support reopening the question. Also, I'm going to go edit my own answer to provide additional clarity to my position on the matter. Thanks for bringing this to the community's attention.

2
  • Thanks. Regarding close reasons; "I would have chosen a close reason of opinion-based, as salesforce.com doesn't really have a 'best practice' regarding storing settings" - true, but it seems like something that could (and I think should) have a best practice. I found this while trying to figure the best way to store a list of selected fields in a special UI on a per-user basis, when the list can exceed 255 characters. I didn't think there was a specific feature, but wanted to be sure I wasn't missing something in an area where a best practice might exist. Commented Apr 21 at 15:55
  • @JasonClark I agree a best practice would be nice. Unfortunately, there's so many variations of this kind of need that there's no one-size-fits-all solution. Custom Settings work with a limited amount of data. localStorage doesn't sync between devices. What we're left with is a "design your own solution" situation, and that might depend on project requirements. However, as I said, I think the question definitely was on-topic for what we do. I do have other alternatives I'm thinking of if I had more info about the project.
    – sfdcfox Mod
    Commented Apr 21 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .