You need to sign in to do that
Don't have an account?
Priya Mishra
static resources file download as csv file
i am saving my excel file in static resources and trying to access in the vf page as a download link in csv format how to download in csv format.
please help me out this ASAP
Thanks in advance.
please help me out this ASAP
Thanks in advance.
Greetings to you!
Instead of storing a .csv file in the static resource, store it in Documents and then download it. It will give you file in .csv format.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
thanks.
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
Note: Test is a Document Name.
Regards,
Khan Anas
so below bold SaveRequest() method is runnig while clicking on the submit button i want this document size check work for one page and not for other page.
Public class SFDC_Access_Controller extends SitesTodHeaderController{
public Case_form_extension_two__c ObjRMS {get;set;}
public string efileName {get;set;}// holds the email attachment name
public transient Blob efileBody {get;set;}// holds the email attachment body
public string datevalue{get;set;}
public Case casvar {set;get;}
public Case Parent_Case{set;get;}
public String SFDC_Form_Value {get;set;}
public List<SelectOption> SFDC_Form_Options {get;set;}
public GBL_Attachments attachmentHelper{get; set;}
public List<String> docIdList = new List<string>();
public boolean pageError {get;set;}
public String pageErrorMessage {get;set;}
public String FormType {get;set;}
public SFDC_Access_Controller(){
SFDC_Form_Options_Config();
casvar =new Case();
attachmentHelper = new GBL_Attachments();
ObjRMS = new Case_form_extension_two__c();
FormType = apexpages.currentPage().getParameters().get('FormType');
}
public PageReference next(){
if(SFDC_Form_Value =='Null'){
Apexpages.addMessage( new ApexPages.Message (ApexPages.Severity.ERROR, 'Please select Type of request'));
}
if(SFDC_Form_Value == 'SFDC Access'){
PageReference pageRef = new PageReference('/apex/SF_Access_Form?FormType='+SFDC_Form_Value);
pageRef.setRedirect(true);
return pageRef;
}
if(SFDC_Form_Value == 'Activate Interviewer'){
PageReference pageRef = new PageReference('/apex/Activate_Interviewer_Form?FormType='+SFDC_Form_Value);
pageRef.setRedirect(true);
return pageRef;
}
return null;
}
public PageReference SaveRequest(){
if(attachmentHelper.UploadedDocumentList.size()==0){
system.debug('attachmentHelper.UploadedDocumentList---' + attachmentHelper.UploadedDocumentList );
Apexpages.addMessage( new ApexPages.Message (ApexPages.Severity.ERROR, 'Please upload documents'));
}
if(attachmentHelper.UploadedDocumentList.size()>0){
System.debug('FormType---' + FormType);
Schema.DescribeSObjectResult d = Schema.SObjectType.Case;
Map<String,Schema.RecordTypeInfo> rtMapByName = d.getRecordTypeInfosByName();
Schema.RecordTypeInfo rtByName = rtMapByName.get('Case');
System.debug('rtByName---'+rtByName);
String caseid = rtByName.getRecordTypeId();
System.debug('caseid---'+caseid);
Schema.DescribeSObjectResult SFAccess_d = Schema.SObjectType.Case_form_extension_two__c;
Map<String,Schema.RecordTypeInfo> SFAccess_rtMapByName = SFAccess_d.getRecordTypeInfosByName();
Schema.RecordTypeInfo SFAccess_rtByName = SFAccess_rtMapByName.get('SF Access');
System.debug('SFAccess_rtByName---'+SFAccess_rtByName);
String SFAccesscaseformexc2id = SFAccess_rtByName.getRecordTypeId();
Schema.DescribeSObjectResult ActivateInterviewer_d = Schema.SObjectType.Case_form_extension_two__c;
Map<String,Schema.RecordTypeInfo> ActivateInterviewer_rtMapByName = ActivateInterviewer_d.getRecordTypeInfosByName();
Schema.RecordTypeInfo ActivateInterviewer_rtByName = ActivateInterviewer_rtMapByName.get('Activate Interviewer');
System.debug('ActivateInterviewer_rtByName---'+ActivateInterviewer_rtByName);
String ActivateInterviewer_caseformexc2id = ActivateInterviewer_rtByName.getRecordTypeId();
Case casvar = new Case();
casvar.Status = 'New';
casvar.Origin = 'Web';
casvar.ContactId = loggedInContact.id;
casvar.WCT_ReportedBy__c = loggedInContact.id;
casvar.Priority = '3 - Medium';
casvar.WCT_Category__c = 'Technology';
if(FormType == 'SFDC Access'){
casvar.WCT_SubCategory1__c = 'Salesforce';
casvar.WCT_SubCategory2__c = 'SFDC Access';
casvar.subject ='SFDC Access';
casvar.description = 'SFDC Access';
}
if(FormType == 'Activate Interviewer'){
casvar.WCT_SubCategory1__c = 'Salesforce';
casvar.WCT_SubCategory2__c = 'Activate Interviewer';
casvar.subject ='Activate Interviewer';
casvar.description = 'Activate Interviewer';
}
system.debug('casvar---' + casvar);
system.debug('SFDC_Form_Value ---' + SFDC_Form_Value );
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.assignmentRuleHeader.assignmentRuleId= Label.Case_Assignment_Rule_Id ;
dmlOpts.EmailHeader.TriggerUserEmail = true;
casvar.setOptions(dmlOpts);
insert casvar;
Case ParentCase= new Case();
ParentCase = [Select id,CaseNumber from Case where id=:casvar.id];
if(FormType == 'SFDC Access'){
ObjRMS.RecordtypeId = SFAccesscaseformexc2id;
ObjRMS.Case_CFE2__c = casvar.id;
insert ObjRMS;
}
if(FormType == 'Activate Interviewer'){
ObjRMS.RecordtypeId = ActivateInterviewer_caseformexc2id;
ObjRMS.Case_CFE2__c = casvar.id;
insert ObjRMS;
}
attachmentHelper.uploadRelatedAttachment(casvar.Id);
PageReference pr = new PageReference('/apex/GBL_Page_Notification?key=SFDC_request&label=HOME&url=/apex/SFDC_request_Home_Form&casenum='+ParentCase.CaseNumber); // redirects to the thank you page
pr.setRedirect(true);
return pr;
}
else{
Apexpages.addMessage( new ApexPages.Message (ApexPages.Severity.ERROR, 'Please upload documents'));
}
return null;
}
public void SFDC_Form_Options_Config(){
SFDC_Form_Options = new List<SelectOption>();
SFDC_Form_Options.add(new SelectOption('Null','--None--'));
SFDC_Form_Options.add(new SelectOption('SFDC Access','SFDC Access'));
SFDC_Form_Options.add(new SelectOption('Activate Interviewer','Activate Interviewer'));
}
}