0

I have a VFP with a few forms that will pull various reports. I want to be able to pull a report and persist the data so when the user logs out of Salesforce, the data will still be there tomorrow. I want the user to not be able to pull the report again.

The one catch is that I am pulling in data from an outside service. How would I go about saving this data to Salesforce? Currently every refresh of the page or log out, the data is cleared and we have to pull the report again.

I have read up on window.name in JavaScript but that appears to only persist when in the same window/tab. Which does not help when the user logs out. I have thought about doing an upsert and saving the data to a variable but I do not see how this would hinder the refreshing of the data. I have thought about static resources but there really isn't any resource being downloaded. It is just a link that is being sent over from the outside server. I have thought about caching and cookies but this is not as safe because someone could clear their cookies or cache.

Is there something in JavaScript or APEX that would allow you to say: if the data has been pulled, freeze the pane forever?

  • "to not be able to", or "not have to"? – sfdcfox Oct 25 '16 at 17:47
2

Users ultimately have control over their own devices, but you can make the data as persistent as long-term cookies via localStorage. This gives you about ~2.5 million characters of data you can store for whatever purpose you desire. Users can still clear out this data, however, so if you absolutely must stop them from calling the service again, use Apex Code. The ideal scenario would probably be a Custom Setting. Just make a hierarchy custom setting with some value, and you can persist data per-user in the object. The only downside here is the limited storage (10MB of data), but otherwise is a great resource to leverage.

  • great suggestions. I am fairly new to Custom Settings but from my experience you can only put one value per setting. How would this work when each report pulled is different? – Olivia Oct 25 '16 at 18:14
  • currently as a work around, I built a custom object and am saving the data into the object. then updating the object with a before trigger. – Olivia Oct 25 '16 at 18:16
  • @Olivia If it's getting to that point, you might need to persist the data elsewhere, perhaps in a record the user doesn't have access to or something. Worst case scenario, you could always store that information out there in the cloud somewhere that's cheaper than salesforce.com storage, possibly in the third-party app itself? – sfdcfox Oct 25 '16 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.