0

Just checking with folks here to understand whether the following idea is possible or not.

The idea is to expose public Site (no login needed) with a file upload functionality.

The end users can choose .csv from their machine when they click on the file upload button.

Once the file is attached and when the user clicks on another button ("Process CSV") the contents of the file will be processed by our batch apex.

Is this possible ?.

1

Yes this is possible. Basically you need to create a Visual Force page that allows an unauthenticated user to create a Document. (Example Here)

Your Apex could then get the attachment (and convert it to a blob).

Alternatively - you can avoid creating a document all together - and capture the upload as a blob directly in your visual Force page (Nice example here)

| improve this answer | |
1

Yes this is doable. Just keep following points in mind

  1. Your will have to temporary store your csv records in a custom object to process via batch apex (Assuming you have huge amount of data to process and that's why you have opted for batch apex). This is because we can't directly pass data to Batch process.
  2. Batch process is an async process and that's why you won't get your results immediately. Store your processed results somewhere and keep checking for that in your page. Use actionPoller vf tag for that.
  3. You will have to provide permissions for your batch apex class and these objects to guest user profile.

Hope this helps.

| improve this answer | |
  • Thanks mate...Can't we convert the file content as blob and proceed with parsing of each individual record ?..I am just thinking why should we have to use a custom object for this ? The number of records will not exceed 500 so I am assuming we won't hit the heap limit also – Varun Jan 13 '16 at 23:32
  • Then why are you considering batch apex? Otherwise just simple process your results in a controller method. – Salesforcesmarty Jan 13 '16 at 23:35
  • Batch apex is always asynch and as such i dont have to worry about heap limits...atleast that what I thought – Varun Jan 13 '16 at 23:38
  • There are certain limits for batch apex, but they are almost double than normal transaction. You can certainly pass the blob to batch apex and do processing, but you will have query any random object (Account) in start method to pass control to execute method. Then process you data there. – Salesforcesmarty Jan 13 '16 at 23:47

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.