function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdc_syedsfdc_syed 

I need to upload only csv file using apex alone how can i do that?

Hi guys,

 

i want upload only csv file format alone using apex how can i do that can any one let me know the step by using apex.

 

Thanks.

IspitaIspita

Hi,

So what do you want to say no intervention of visual force?

Points to ponder:-

  • How will apex know which file to upload? For that u will need a VF UI perhaps
  • Or this what you do - designate a folder in documents for files you want to upload via apex
  • Now your scheduled apex on a daily basis reads all new files created from there.
  • Adopting such an approach may eliminate the use of API intervention or even Visual Force coding.

Hope this helps...

sfdc_syedsfdc_syed

Hi ,

 

i just want to know that how will apex know which file to upload i.e wether it is. csv file or not ?i need  process of that  how it will work and give me the example.

 

Thanks 

Sridhar BonagiriSridhar Bonagiri

Hi,

 

Uploading using apex alone means what ? , 

 

Do you want any UI for this or not ?

 

Sridhar Bonagiri

sfdc_syedsfdc_syed

HI,

 

it  meas that,i have scenario like uploading the data into custom object.wat  i want is when browse any csv file how do i check whether it is csv file or not in apex?if it is csv file then only we can browse  other wise it should display error message.so explain me with example i.e. apex code.

 

Thanks

IspitaIspita

Hi,

you can store the file name in a field asnd then using string function check the extension if its .csv you can go ahead and can have robust error handling to tide over any other exception encountered.

 

Hope this helps....

sfdc_syedsfdc_syed

Hi,

 

Can you explain me with apex code i.e. how apex know whether it is csv file or not?

 

Thanks

IspitaIspita

Hi Syed,

I think you will be using some UI to upload the documents , as you upload your file surely the name of the file will also get captured and its not getting captured develop custom code to get it done ensure iots not editable by users . Now you can make use of this filename to verify if the file is csv or not. further more to make error handling foolproof you can ensure proper error handling so that if somehow a non-csv file gets uploaded you can generate proper error messages.

 

Hope this helps....