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
AvLavAvLav 

test upload file

Hy everybody!

 

I have this code in my controller :

 

// upload documents and navigate to the next page public PageReference doSave() { Document d = (Document) controller.getRecord(); d.folderid = System.UserInfo.getUserId(); //store in Personal Documents insert d; return Page.dgw_auxilary; }

 of course my controller is extends the documents apex standard controller.

Is anybody know, how can I test this code? I have no idea.

 

 

MiddhaMiddha

Should be something like this:

 

 

Document d = [Select Id from Document limit 1];ApexPages.StandardController oVB = new ApexPages.StandardController(d);ControllerClass c = new ControllerClass(oVB);c.doSave();

 

/G 

 

 

DEV_NAVATARDEV_NAVATAR

You can test your uploaded document by putting in the system.debug in your code before redirecting your page. Test in your code by adding in few extra line sto your code. ie.


public PageReference doSave() {
Document d = (Document) controller.getRecord();
d.folderid = System.UserInfo.getUserId();
Database.SaveResult sr = Database.Insert(d);
if(sr.isSuccess() == true)
{
System.debug(‘Document successfully uploaded’);
return Page.dgw_auxilary;
}
Else
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, ‘Error Message'));
Return null;
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.