You need to sign in to do that
Don't have an account?
Deepu Gupta 29
VF page is working fine in Browser but not in SF1
Hi All,
I have created a link in Account Hierarchy(inline VF Page) Section under Account Detail Page which is navigating me on another page where this whole Hierachy shown and two other links are given which is navigating me on another VF page its working fine in browser but not working in SF1.Navigating code is written in this controller which i am sharing.I have enable the checkbox in VF page to Available for Salesforce mobile apps and Lightning Pages.
I have created a link in Account Hierarchy(inline VF Page) Section under Account Detail Page which is navigating me on another page where this whole Hierachy shown and two other links are given which is navigating me on another VF page its working fine in browser but not working in SF1.Navigating code is written in this controller which i am sharing.I have enable the checkbox in VF page to Available for Salesforce mobile apps and Lightning Pages.
<apex:page standardController="Account" tabStyle="Account" extensions="WithContactButtonController"> <apex:form > <apex:pageBlock > <apex:pageBlockSection title="Account Hierarchy" columns="2"> <c:HierarchyTree currId="{!Account.id}" /> </apex:pageBlockSection> </apex:pageBlock> <script> var url = location.href; var match = url.match(/inline=1/); if (match != null) { var newUrl = url.replace(/inline=1/, ''); window.top.location=newUrl; } </script> <table align ="centre"> <tr> <td><b><apex:commandLink action="{!Cancel}" target="_top" value="BacktoAccount" id="theButton1"/></b></td> <td></td> <td></td> <td><b><apex:commandLink action="{!IncludeContactpage}" target="_top" value="IncludeContact" id="theButton"/></b></td> </tr> </table> </apex:form> </apex:page>
public with sharing class WithContactButtonController { private ApexPages.StandardController standardController; public Id currId= apexpages.currentpage().getparameters().get('Id'); public WithContactButtonController(ApexPages.StandardController standardController) { this.standardController = standardController; } public PageReference renderforShowAccHierarchy() { // Apex code for handling record from a Detail page goes here //Id recordId = standardController.getId(); //PageReference pageRef = new PageReference('/apex/HierarchyPage1?retURL=/apex/HierarchyPage?Id='+standardController.getId()); PageReference pageRef = new PageReference('/apex/HierarchyPage1?Id='+currId); pageRef.setRedirect(true); return pageRef ; } public PageReference IncludeContactpage() { // Apex code for handling record from a Detail page goes here PageReference pageRef1 = new PageReference('/apex/Hierarchy_Clone?Id='+currId); pageRef1.setRedirect(true); return pageRef1; } }
Like:
'javascript:sforce.one.navigateToURL(url)';
Refer: https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/salesforce1_dev_jsapi_sforce_one.htm
Hope this helps
Veenesh
You can check if the page is open in SF1 or not by using below code in javaScript and then open the Page accordingly:
Include above code in a JavaScript function and call the same onclick of hyperlink.
I have written the code which you shared in the onclick javascript of the command link that is Include Contact which is there in Hierarchypage1 and suppose to navigate me on Hierarchy_Clone page.but still i am not able to see this link in my sf1.the code which i modified in HierarchyPage1 is as follows : Please let me know how to get visible that link in sf1.
@Veenesh Vikram is 100% correct. Use JS to redirect instead of controller method. PFB code snippet
Note: I have used accountID from the URL, replace it with your variable.
Thanks & Regards,
Viru
Still i am not able to see this link in my sf1.