SlideShare a Scribd company logo
1 of 2
Sample code to create files on your desktop
using APEX
From time totime;there comesa requirementtowrite afile toyour desktopandthenhave itFTP over
to anotherlocation.
Openan APEXpage and copy the followingtest code:
<apex:page controller="GenerateContactTXT"contentType="text/plain#Contact.txt"cache="true">
"Title","FirstName","LastName"
<apex:repeatvalue="{!Contacts}"var="con">
<apex:repeatvalue="{!con}"var="asub">
"{!asub.Title}","{!asub.FirstName}","{!asub.LastName}"
</apex:repeat>
</apex:repeat>
</apex:page>
Create a class GenerateContactTXT:
public Class GenerateContactTXT{
public List<Contact> getContacts() {
return [selectId,Title,FirstName,LastName from Contactlimit20];
}
}
Load your APEX page and you should be able to have the file downloaded to your desktop.

More Related Content

Viewers also liked

Pharma24bd.DELAR QUOTATION
Pharma24bd.DELAR QUOTATIONPharma24bd.DELAR QUOTATION
Pharma24bd.DELAR QUOTATIONG M ISLAM
 
ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...
ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...
ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...PHARMADVISOR
 
DIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONS
DIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONSDIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONS
DIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONSIAEME Publication
 
Humanoid robot by mitesh kumar
Humanoid robot by mitesh kumarHumanoid robot by mitesh kumar
Humanoid robot by mitesh kumarMitesh Kumar
 
NinjaScript 2010-10-14
NinjaScript 2010-10-14NinjaScript 2010-10-14
NinjaScript 2010-10-14lrdesign
 
Drupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commandsDrupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commandsMichael Miles
 
BSSML16 L3. Clusters and Anomaly Detection
BSSML16 L3. Clusters and Anomaly DetectionBSSML16 L3. Clusters and Anomaly Detection
BSSML16 L3. Clusters and Anomaly DetectionBigML, Inc
 
Οι κάψουλες της Ιαπωνίας
Οι κάψουλες της ΙαπωνίαςΟι κάψουλες της Ιαπωνίας
Οι κάψουλες της ΙαπωνίαςPiperaki Eleni
 
BSSML16 L2. Ensembles and Logistic Regressions
BSSML16 L2. Ensembles and Logistic RegressionsBSSML16 L2. Ensembles and Logistic Regressions
BSSML16 L2. Ensembles and Logistic RegressionsBigML, Inc
 
Stunning Glasswing Butterfly - Greta oto
Stunning Glasswing Butterfly  -  Greta otoStunning Glasswing Butterfly  -  Greta oto
Stunning Glasswing Butterfly - Greta otoMakala D.
 
The 2015 Sony world photography awards entries
The 2015 Sony world photography awards entriesThe 2015 Sony world photography awards entries
The 2015 Sony world photography awards entriesMakala D.
 

Viewers also liked (16)

Pharma24bd.DELAR QUOTATION
Pharma24bd.DELAR QUOTATIONPharma24bd.DELAR QUOTATION
Pharma24bd.DELAR QUOTATION
 
ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...
ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...
ICH S4 (Duration of Chronic Toxicity Testing in Animals (Rodent and Non Roden...
 
Lkti aaaaa
Lkti aaaaaLkti aaaaa
Lkti aaaaa
 
DIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONS
DIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONSDIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONS
DIGITAL DIVIDE IN THAILAND: ANALYSIS AND RECOMMENDATIONS
 
Humanoid robot by mitesh kumar
Humanoid robot by mitesh kumarHumanoid robot by mitesh kumar
Humanoid robot by mitesh kumar
 
NinjaScript 2010-10-14
NinjaScript 2010-10-14NinjaScript 2010-10-14
NinjaScript 2010-10-14
 
ION Bangladesh - ISOC Dhaka Chapter Welcome
ION Bangladesh - ISOC Dhaka Chapter WelcomeION Bangladesh - ISOC Dhaka Chapter Welcome
ION Bangladesh - ISOC Dhaka Chapter Welcome
 
ION Bangladesh - IPv6 Experiences at Sri Lanka Telecom
ION Bangladesh - IPv6 Experiences at Sri Lanka TelecomION Bangladesh - IPv6 Experiences at Sri Lanka Telecom
ION Bangladesh - IPv6 Experiences at Sri Lanka Telecom
 
Drupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commandsDrupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commands
 
BSSML16 L3. Clusters and Anomaly Detection
BSSML16 L3. Clusters and Anomaly DetectionBSSML16 L3. Clusters and Anomaly Detection
BSSML16 L3. Clusters and Anomaly Detection
 
Menus 5
Menus 5Menus 5
Menus 5
 
Οι κάψουλες της Ιαπωνίας
Οι κάψουλες της ΙαπωνίαςΟι κάψουλες της Ιαπωνίας
Οι κάψουλες της Ιαπωνίας
 
A Ferrovia em Portugal
A Ferrovia em PortugalA Ferrovia em Portugal
A Ferrovia em Portugal
 
BSSML16 L2. Ensembles and Logistic Regressions
BSSML16 L2. Ensembles and Logistic RegressionsBSSML16 L2. Ensembles and Logistic Regressions
BSSML16 L2. Ensembles and Logistic Regressions
 
Stunning Glasswing Butterfly - Greta oto
Stunning Glasswing Butterfly  -  Greta otoStunning Glasswing Butterfly  -  Greta oto
Stunning Glasswing Butterfly - Greta oto
 
The 2015 Sony world photography awards entries
The 2015 Sony world photography awards entriesThe 2015 Sony world photography awards entries
The 2015 Sony world photography awards entries
 

Sample code to create files on your desktop using APEX

  • 1. Sample code to create files on your desktop using APEX
  • 2. From time totime;there comesa requirementtowrite afile toyour desktopandthenhave itFTP over to anotherlocation. Openan APEXpage and copy the followingtest code: <apex:page controller="GenerateContactTXT"contentType="text/plain#Contact.txt"cache="true"> "Title","FirstName","LastName" <apex:repeatvalue="{!Contacts}"var="con"> <apex:repeatvalue="{!con}"var="asub"> "{!asub.Title}","{!asub.FirstName}","{!asub.LastName}" </apex:repeat> </apex:repeat> </apex:page> Create a class GenerateContactTXT: public Class GenerateContactTXT{ public List<Contact> getContacts() { return [selectId,Title,FirstName,LastName from Contactlimit20]; } } Load your APEX page and you should be able to have the file downloaded to your desktop.