0

I have Account.txt file to create Account records from Static Resource,how can i read Account.txt file in visualforce page?

<apex:page >
  <apex:form >
  <apex:commandButton value="Get Data From Txt"/>
  </apex:form>
</apex:page>

and I have data in the Account.txt as below:

sobject-'Account' Name='ram' Name='hari'

2

One of the solution could be you can query on Static Resource object and get the body of that resource and then Process logic accordingly.

StaticResource srObject = [select id,body from StaticResource Where Name = 'SOME RESOURCE NAME'];
String contents = srObject.body.toString();
for(String line:contents.split('\n')) {
  // Process Logic Here
}

You can also check this useful blog

  • 1:53:01.0 (52364002)|USER_DEBUG|[7]|DEBUG|contents sobject-'Account' Name='ram' Name='hari' 11:53:01.0 (523862,,how can i pull out Sobject and Name colum,,can u please tel me how to do it,, – Satya Aug 10 '16 at 6:24
  • i had gone gone through your blog,still i didnot get an idea how to create Account records from Account.txt file – Satya Aug 10 '16 at 6:37
  • if u can help how to create records using getting the object name from the .txt will be very help full for me – Satya Aug 10 '16 at 8:07

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.