You need to sign in to do that
Don't have an account?
Padmini S 26
PageReference is not redirecting in communities
Hi,
I have written the below visualforce page and Apex class for creating the Opportunity Product. It is working fine in salesforce . When I opened in salesforce Community , I am not able to create opportunity product and not able to redirect to another visualforce page. I have given visualforce page and apex class access to community user profile. But it is redirects to Error occurred while loading a Visualforce page.
I have written the below visualforce page and Apex class for creating the Opportunity Product. It is working fine in salesforce . When I opened in salesforce Community , I am not able to create opportunity product and not able to redirect to another visualforce page. I have given visualforce page and apex class access to community user profile. But it is redirects to Error occurred while loading a Visualforce page.
Visualforce page: <apex:page standardController="Pricebookentry" extensions="productcontroller" sidebar="false" showHeader="false" applyBodyTag="false"> <html lang="en"> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" ></script> <script src="https://www.amcharts.com/lib/3/amcharts.js"></script> <script src="https://www.amcharts.com/lib/3/serial.js"></script> <script src="https://www.amcharts.com/lib/3/themes/light.js"></script> <apex:stylesheet value="{!URLFOR($Resource.BootCss)}" /> <apex:includeScript value="{!URLFOR($Resource.Chart1)}"/> <apex:includeScript value="{!URLFOR($Resource.JS)}" /> <apex:includeScript value="{!URLFOR($Resource.bootJs)}" /> <script> function alertSample() { alert("You have booked Successfully"); } </script> <style> .container-fluid { margin-top: 10px; } #chartdiv { width : 400px; height : 200px; font-size : 11px; } </style> </head> <body> <apex:form > <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src='{!URLFOR($Resource.Header)}' alt="New York"/> <div class="carousel-caption"> <h3>New York</h3> <p>The atmosphere in New York is lorem ipsum.</p> </div> </div> <div class="item"> <img src='{!URLFOR($Resource.Header)}' alt="Chicago"/> <div class="carousel-caption"> <h3>Chicago</h3> <p>Thank you, Chicago - A night we won't forget.</p> </div> </div> <div class="item"> <img src='{!URLFOR($Resource.Header)}' alt="Los Angeles"/> <div class="carousel-caption"> <h3>LA</h3> <p>Even though the traffic was a mess, we had the best time.</p> </div> </div> </div> </div> <div class="container-fluid"> <div id="header"></div> <div class="panel panel-default"> <div class = "panel-table" style="float: left;width: 900px;"> <div class="panel-body" > <div class="panel panel-success"> <div class="panel-heading">Prodcut Search</div> <div class="panel-body"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="aName">Products Category</label> <apex:selectList value="{!selectedCategory}" multiselect="false" size="1"> <apex:selectOptions value="{!productOptions}"/> </apex:selectList> <apex:commandButton value="Search Product" action="{!SearchProduct}" /> </div> </div> </div> </div> </div> <div class="panel panel-info"> <div class="panel-heading"><div> Products Information <apex:commandButton value="Book" action="{!Book}" onclick="alertSample();" style="float: right;"/> </div> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> </button> </div> </div> </div> </div> </div> <div class="panel-body"> <apex:outputPanel id="productTable"> <table class="table table-condensed"> <tr> <th>Select</th> <th>Product name</th> <th>Product Category</th> <th>Product Price</th> <th> Quantity</th> <th>Image</th> </tr> <apex:outputpanel rendered="{!IF((selectedCategory == NULL) , true,false)}"> <apex:repeat value="{!productlist1}" var="prod1" > <tr> <td> </td> <td> <apex:outputField value="{!prod1.Product2.Name}" /> </td> <td> <apex:outputField value="{!prod1.Product2.Family}" /> </td> <td> <apex:outputField value="{!prod1.UnitPrice}" /> </td> <td> <apex:inputField value="{!prod1.Product2.Quantity__c}" /> </td> <td> <apex:outputField value="{!prod1.Product2.ProductPicture__c}" /> </td> </tr> </apex:repeat> </apex:outputpanel> <apex:outputpanel rendered="{!IF((selectedCategory!= NULL) , true,false)}" id="pageblock1"> <apex:repeat value="{!productlist}" var="prod" > <tr> <td> <apex:outputPanel id="counter2"> <input type="radio" name="sel" /> <apex:actionsupport action="{!process}" event="onchange" rerender="abc"> <apex:param name="select" value="{!prod.Product2.Id}" assignTo="{!str}"/> </apex:actionsupport> </apex:outputPanel> </td> <td> <apex:outputField value="{!prod.Product2.Name}" /> </td> <td> <apex:outputField value="{!prod.Product2.Family}" /> </td> <td> <apex:outputField value="{!prod.UnitPrice}" /> </td> <td> <apex:inputText value="{!prod.Product2.Quantity__c }" /> </td> <td > <apex:outputField value="{!prod.Product2.ProductPicture__c}" /> </td> </tr> </apex:repeat> </apex:outputpanel> </table> </apex:outputPanel> </div> </div> </div> </div> </div> </div> </apex:form> </body> </html> </apex:page> Apex Class: public without sharing class productcontroller { public Product2 pro{get;set;} public Pricebookentry productlist{get;set;} public OpportunityLineItem oppLineItem{get;set;} Public Boolean flag {get;set;} Public string str {get;set;} Public Product2 records {get;set;} public List<Pricebookentry> productlist1{get;set;} public string selectedAsset {get;set;} public string selected{get;set;} public String selectedCategory{get;set;} public productcontroller(ApexPages.StandardController controller) { pro = new Product2(); productlist1 = [SELECT Id,Name,Product2.Id,Product2.Name,Product2.Family,Product2.Quantity__c ,Product2.Product_Category__c,Product2.ProductPicture__c,Product2.ProductCode,UnitPrice FROM Pricebookentry LIMIT 2]; } public void SearchProduct() { productlist = [SELECT Id,Name,Product2.Id,Product2.Name,Product2.Family,Product2.Quantity__c ,Product2.ProductPicture__c,Product2.ProductCode,UnitPrice FROM Pricebookentry where PriceBook2.IsStandard=true AND Product2.Family =:selectedCategory]; system.debug('**********' + pro.Family); } public PageReference process() { flag = false; return null; } public PageReference Book() { Opportunity opp = new Opportunity(); opp.Name = 'Test Opportunity'; opp.CloseDate= System.Today(); opp.StageName='Open'; insert opp; system.debug('str****************' + str); oppLineItem = new OpportunityLineItem(); if ( str != null) { oppLineItem.OpportunityId = opp.Id; oppLineItem.PricebookEntryId = productlist.Id; // oppLineItem.Product2.Id = str; oppLineItem.UnitPrice = productlist.UnitPrice; oppLineItem.Quantity = productlist.Product2.Quantity__c; oppLineItem.Status__c = 'Open'; oppLineItem.Sub_Status__c = 'Order Received'; insert oppLineItem; return null; } PageReference ref = Page.oppproddetailpage; ref.getParameters().put('selectedAsset', oppLineItem.Id); ref.setRedirect(true); return ref; } } public List<SelectOption> getproductOptions() { List<SelectOption> countryOptions = new List<SelectOption>(); countryOptions.add(new SelectOption('','-None-')); countryOptions.add(new SelectOption('Vibration Speakers','Vibration Speakers')); countryOptions.add(new SelectOption('LED H Series','LED H Series')); return countryOptions; } }Could please help on this issue. Thanks in Advance.
Thank you for your help. Below are the screenshot and URL.
URL : https://abajworlddemo1-developer-edition.ap2.force.com/partners/prodcutsearch