You need to sign in to do that
Don't have an account?
ShadowlessKick
Salesforce Classic to Lightning
Trying to duplicate a process that was developed in Salesforce Classic. What should happen is a method in a controller should be launched on page load of a visual force page, the constructor should do some work and return a parm to the visualforce page. Do not want to click more buttons other than the initial "action button" that calls a visualforce page. Could someone please explain what is in error here? Is this the correct path to take?
<apex:page standardController="Opportunity" extensions="opportunityMockUp" showQuickActionVfHeader="false"> <script> window.onload = new function() { buildURL(); }; function buildURL() { //Just a container to launch the action button }; </script> <script> function navigateToMockUp(){ if ( (typeof sforce != 'undefined') && (sforce != null) ) {s alert('{!theBuiltURL}'); sforce.one.navigateToSObject('{!theBuiltURL}'); } else { window.location='/' + '{!theBuiltURL}'; } } </script> <apex:form > <apex:actionFunction name="buildURL" action="{!autoRun}" rerender="none" oncomplete="navigateToMockUp();"> </apex:actionFunction> </apex:form> </apex:page>
public with sharing class opportunityMockUp{ //Define the Project Object Opportunity theOpportunity = new Opportunity(); String thePageOpportunityId; String theOpportunityID; String theOppName; String theAccountID; String theAmount; String theOppNumber; String theQuote; String theSalesRep; String theDistrictName; String theRegion; String theProjectCoordinator; String theMockUpName; String theTarget; String theParameters; String theValues; String theURL; String theAccountName; public String theBuiltURL {get;set;} // Constructor - this only really matters if the autoRun function doesn't work right public opportunityMockUp(ApexPages.StandardController stdController) { this.theOpportunity = (Opportunity)stdController.getRecord(); } // Code invoked on page load. public PageReference autoRun() { thePageOpportunityId = ApexPages.currentPage().getParameters().get('id'); if (thePageOpportunityId == null) { // Display the Visualforce page's error message if no Id is passed over return null; } for (Opportunity theOpportunity:[select Id, Name, Accountid, Account.Name, Amount, Opportunity_Number__c, KI_Quote__c, Sales_Representative__c,District_Name__c,Region__c, Project_Coordinator__c, KCO_Competition_Current_Suppliers__c from Opportunity where id =:thePageOpportunityId Limit 1]) { theTarget = '&00N50000002pCh2'; theParameters = ''; theValues = theOpportunity.KCO_Competition_Current_Suppliers__c; if (theValues != null && theValues != '' && theValues != '0'){ List<String> theValueArray = theValues.split(';'); for (integer i=0; i < theValueArray.size(); i++) { theParameters = theParameters + theTarget + '=' + theValueArray[i] ; system.debug('TheParms: ' + theParameters); } } else { theParameters = ''; } theMockUpName = 'Mock Up: ' + theOpportunity.Name; theAmount = String.ValueOf(theOpportunity.Amount); if (theAmount != null && theAmount != '') { theAmount = theAmount.Substring(0,3); } else { theAmount = '0'; } theOpportunityID = theOpportunity.Id; theAccountID = theOpportunity.Accountid; theAccountName = theOpportunity.Account.Name; theOppName = theOpportunity.Name; theOppNumber = theOpportunity.Opportunity_Number__c; theQuote = theOpportunity.KI_Quote__c; if (theOpportunity.KI_Quote__c != null && theOpportunity.KI_Quote__c != '') { theQuote = theOpportunity.KI_Quote__c; } else { theQuote = ''; } theSalesRep = theOpportunity.Sales_Representative__c; theDistrictName = theOpportunity.District_Name__c; theRegion = theOpportunity.Region__c; theProjectCoordinator = theOpportunity.Project_Coordinator__c; theOpportunityID = theOpportunity.id; TheURL = '/a0G/e?CF00N500000026uRE=' + theOppName + '&CF00N500000026uR5=' + theAccountName + '&00N50000002pCi0=' + theOppNumber + '&00N50000002pCuV=' + theQuote + '&00N500000026uRM=' + theSalesRep + '&00N50000002pCmW=' + theDistrictName + '&00N50000002pCmb=' + theRegion + theParameters + '&00N500000026uRK=' + theAmount + '&00N500000026uRK=' + theProjectCoordinator + '&Name=' + theMockUpName + '&retURL=/' + theOpportunityID + ' target="blank"'; system.debug('TheURL 1: = ' + TheURL); //TheURL = EncodingUtil.URLENCODE(TheURL,'UTF-8'); system.debug('TheURL 2: = ' + TheURL); theBuiltURL = TheURL; } return null; }
And the controller.
All Answers
https://developer.salesforce.com/blogs/developer-relations/2015/03/lightning-components.html
Including Lightening component into Visualforce page and passing parameter through VF page to Lightening component.
https://satti-salesforce.blogspot.com/b/post-preview?token=1MeO6VEBAAA.N4qll1Gul7EYGKTAwFpTJf4y9hU2D8wOr6y-FxfYRpADq6ediiEKho0SB_ZOZGlneVM3ajxVg0ODRTsjlkX9yg.cPjI3BjVvPjuzqYRRSLnRw&postId=7458652044440064044&type=POST
And the controller.