+ Start a Discussion
Denise CrosbyDenise Crosby 

trouble redirecting to event page on SF1 for event I created in custom controller

Hi. I have a VF page with custom controller on a global action to create an event. After saving, I need the SF1 mobile app to redirect to the event I just created. I've research this and tried several things, but nothing seems to work on mobile.

I tried the below in my save method, but I get "You can't view this page, either because you don't have permission or because the page isn't supported on mobile devices."
insert ev;
PageReference nextPage = new PageReference('/one/one.app#/sObject/' + ev.Id);
    return nextPage;
I've also tried this, but it does nothing:
 
insert ev;
return new ApexPages.StandardController(ev).view();
How can I get this working on a mobile device? Thanks !


 
Alain CabonAlain Cabon
Did you tried setRedirect(true);​  ?
insert ev;
PageReference evtPage = new ApexPages.StandardController(ev).view();
evtPage.setRedirect(true);
return evtPage;
Alain CabonAlain Cabon
  • You have a checkbox  Available for Salesforce mobile apps and Lightning Pages avalaible for every VFP but that must be checked only if you want to use these VFP as components into a Lightning Page.
  • but Custom Buttons and Links in the Salesforce1 app: 
  1. The Visualforce page must also have the "Available for Salesforce Mobile Apps" checkbox selected.
  2. Setup > Visualforce page > Edit 
https://help.salesforce.com/articleView?id=Salesforce1-Are-Custom-Buttons-Links-Supported-in-the-Salesforce1-App&language=en_US&type=1
Alain CabonAlain Cabon
You can verify easily all your pages with this request from the developer console:

Query editor:  select id, name,apiversion,isavailableintouch from apexpage

isavailableintouch = true : available for the SF1

You can even update this value for many pages with SOQL or the dataloader without looking at every page manually (I had changed this value globally for my own needs)
 
Denise CrosbyDenise Crosby
Yes, Alain,
On my custom VF page, I have "Available for LIghtning Experience, Salesforce1, and Lightning Communities" selected under Setup > Visualforce page > Edit. I don't think that's a problem because my custom page is displaying fine. It's only the redirect to the Event page after saving that I'm still trying to get to work. 
Denise CrosbyDenise Crosby
Alain,
I tried your code, but it still does not navigate to the event page. 
insert ev;
PageReference evtPage = new ApexPages.StandardController(ev).view();
evtPage.setRedirect(true);
return evtPage;

 
Alain CabonAlain Cabon
What is the error now? (always "You can't view this page, either because you don't have permission or because the page isn't supported on mobile devices." )
Denise CrosbyDenise Crosby
No. With your code, the page saves and then redirects to the home "Chatter" page on the mobile device.
Denise CrosbyDenise Crosby
sorry Alain, I thought you wanted to chat... No, the screen is navigating to the Chatter screen, which is my home screen on Salesforce1. I need it to navigate to the new event screen instead, but it's not working. I am still investigating. Thanks for your help here.
Denise CrosbyDenise Crosby
I need it to navigate to the event screen (the event that was just created)
Denise CrosbyDenise Crosby
For now, since I have to demo this in 2 days, I am simply showing a success message in my save method and staying on the same page.
insert ev;
ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.CONFIRM,' Meeting Created Successfully. Thank you!'));
return null;
I'm still working on navigating to the new event that was created after pressing Save.
 
Alain CabonAlain Cabon
Hi Denise,
insert ev;
PageReference nextPage = new PageReference('/one/one.app?source=aloha#/sObject/' + ev.Id + '/view');
nextPage.setRedirect(true);
return nextPage;
That could work.
Denise CrosbyDenise Crosby
Hi Alain,
Thank you for responding. I used your code and got the dreaded "You can't view this page, either because you don't have permission or because the page isn't supported on mobile devices." I think I better stick with my simple message and stay on the same screen for now. I have 1 day left until my demo. If the big bosses don't complain about it, I'll just go with that. Thanks again... I'd still like to figure out what the heck is wrong! BTW, I did Google the error message and found out this was a similar known issue that was fixed in Summer '16 patch?!?

https://success.salesforce.com/issues_view?id=a1p300000008Y8KAAU
Alain CabonAlain Cabon
Ok it is a problem for your Salesforce 1. If you find or get a solution, post it here but your problem is clearly not solved yet.
Denise CrosbyDenise Crosby
Alain,
Does the code you provided here work for your Salesforce 1 or in general, for Salesforce 1? It sounds like the problem could be with my Salesforce 1 specifically or my instance. If so, I will open a support ticket with Salesforce. Thanks again for all your great help.