• John ag 8
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi everyone, I'm relatively new to Lightning so please be gentle.

I'm in the process of trying to replace javascript buttons with Lightning buttons, and I've come across and Opportunity button that navigates to an external URL that passes along a variety of parameters:

I wanted to create a Lightning button that navigates to this URL with a confirmation dialog prior to navigation, so I created a Lightning Component to try to achieve this.

At the time of this post, I did not create any apex controllers for this.

Component:
 
<aura:component                 implements="force:lightningQuickActionWithoutHeader,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" 
				access="global" >
	
    <!-- Include Static Resources - if any -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

Controller:
doInit: function( cmp, event, helper )
{
  // Obtain Parameters for URL
  var OpportunityId = cmp.get("v.recordId");
  var CustomerId = [??]; // Used to be {!Account.CustomerID__c}
  var API_Session_ID = [??]; // Used to be {!API.Session_ID}
  var API_Partner_Server_URL = [??]; // Used to be {!API_Partner_Server_URL_70}
  var User_Company_Id = [??]; // Used to be {!User.Company_Id__c}

  // Navigate to URL
  var urlEvent = $A.get("e.force:navigateToURL");
  urlEvent.setParams({
      "url": 'https://www.[website].com/action?" + [Parameters=Values List above]
   });

  // Confirm prior to navigation
  if ( confirm ("You are about to initiate a transaction on [website], please ensure you examine all necessary fields as per documentation" ))
  {
    urlEvent.fire();
  }
  
}

How do I obtain the parameters in order to achieve this? 

 
  • December 04, 2018
  • Like
  • 0