2

I'm using a custom_object and once the user save I want that page to redirect to list view page but what is happening is that right after i click save button i see the white blank screen with the following URL

https://XXXX.visual.force.com/apex/Employee?retURL=%2Fa00%2Fo&save_new=1&sfdc.override=1

Here is the code I have used:

I have tried this code:

Schema.DescribeSObjectResult anySObjectSchema = Employee__c.SObjectType.getDescribe();
String objectIdPrefix = anySObjectSchema.getKeyPrefix();
PageReference pageReference = new PageReference('/'+objectIdPrefix+'/o');
pageReference.setRedirect(true);
return pageReference;

and this code: (hard code the prefix) still does not work:

PageReference pageRef = new PageReference('/a00/o'); 
pageRef.setRedirect(true); 
return pageRef;  
0
0

you could use inside your command button or link oncomplete="window.open('/a00', '_blank', height=400,location=no,resizable=yes,toolbar=no,status=no,me‌​nubar=no,scrollbars=‌​1', 1);"

OR Using a commandlink because you can set the target

`   public PageReference ReturnToList(){
    //do something here or no
    return new PageReference('/' + Employee__c.sObjectType.getDescribe().getKeyPrefix());
    }`
4
  • i do not like to use any javascript and i'm sure there is better way of doing than this. – Nick Kahn Sep 23 '16 at 2:10
  • Hi Nick, if you don't like js then the second option should do it. I hope it helps. – Carlos Sep 23 '16 at 20:35
  • Still have the same issue after I click save button, I see the blank white screen with the url I posted in my question – Nick Kahn Sep 23 '16 at 23:07
  • That's weird, those are two valid ways to accomplish what you need. I use these approaches all the time. I don't think you problem is in the code. I would check user permissions or page security. Good luck! – Carlos Sep 26 '16 at 15:28

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.