You need to sign in to do that
Don't have an account?
Radhika pawar 5
Upload the file Document in separate Folder
Senario: when i upload the file ,its saves in my personal Document
But my Requirement is it should be saved in Different folders name/separate Name
eg:SMS Imgica,Read in india etc.
Hey guys please give me solution for below code:
public with sharing class ctrlDocumentInfo
{
public String FolderName {get;set;}
public String folder { get; set; }
public ctrlDocumentInfo()
{FolderName = '';
}
public Document document {
get {
if (document == null)
document = new Document();
return document;
}
set;
}
public List<SelectOption> getAttFold()
{
List<SelectOption>lstfold = new List<SelectOption>();
for(folder objFolder:[select id,name from folder where type='document' ]){
lstfold.add(new SelectOption(objFolder.id, objFolder.Name));
}
return lstfold;
}
public PageReference upload()
{
document.AuthorId = UserInfo.getUserId();
//Folder f=[SELECT Id,Name FROM Folder WHERE Folder.Name = 'SMS Magic' ];
document.FolderId = UserInfo.getUserId(); // put it in running user's folder
// document.folderId = f;
try {
insert document;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
return null;
} finally {
document.body = null; // clears the viewstate
document = new Document();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
return null;
}
}
But my Requirement is it should be saved in Different folders name/separate Name
eg:SMS Imgica,Read in india etc.
Hey guys please give me solution for below code:
public with sharing class ctrlDocumentInfo
{
public String FolderName {get;set;}
public String folder { get; set; }
public ctrlDocumentInfo()
{FolderName = '';
}
public Document document {
get {
if (document == null)
document = new Document();
return document;
}
set;
}
public List<SelectOption> getAttFold()
{
List<SelectOption>lstfold = new List<SelectOption>();
for(folder objFolder:[select id,name from folder where type='document' ]){
lstfold.add(new SelectOption(objFolder.id, objFolder.Name));
}
return lstfold;
}
public PageReference upload()
{
document.AuthorId = UserInfo.getUserId();
//Folder f=[SELECT Id,Name FROM Folder WHERE Folder.Name = 'SMS Magic' ];
document.FolderId = UserInfo.getUserId(); // put it in running user's folder
// document.folderId = f;
try {
insert document;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
return null;
} finally {
document.body = null; // clears the viewstate
document = new Document();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
return null;
}
}
saves document in logged in user personal folder. You have to use different folder to save the document in different folder.