function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC cloud  GuySFDC cloud Guy 

how to use custom button links in lightning

I want to place a custom button in existing component and once i click on that button need to open a new window with the existing visual force page please suggest me 
Best Answer chosen by SFDC cloud Guy
Shun KosakaShun Kosaka
Hi,
Here is the simplest way.
<input type="button" value="click" onclick="window.open('/apex/YOURVFPAGENAME')" />

You can also use standard component <ui:button> like below,
<ui:button label="click" press="{!c.openVisualForcePage}" />
In this case, you need to controller.js like below,
({
	openVisualForcePage : function(component, event, helper) {
		window.open('/apex/YOURVFPAGENAME');
	}
})

 

All Answers

Shun KosakaShun Kosaka
Hi,
Here is the simplest way.
<input type="button" value="click" onclick="window.open('/apex/YOURVFPAGENAME')" />

You can also use standard component <ui:button> like below,
<ui:button label="click" press="{!c.openVisualForcePage}" />
In this case, you need to controller.js like below,
({
	openVisualForcePage : function(component, event, helper) {
		window.open('/apex/YOURVFPAGENAME');
	}
})

 
This was selected as the best answer
SFDC cloud  GuySFDC cloud Guy
Thanks shun kosaka
one more  question is the visuals force page I am using lightning component,its display some details of account ,here how can i pass the record id 
 
Shun KosakaShun Kosaka
Do your lightning component have an attribute of record id?
In the lightning component,
<aura:attribute name="recordId" type="Id" />
<ui:button label="click" press="{!c.openVisualForcePage}" />
You can retrieve record id by component.get("v.recordId"). So, modify contoller.js slightly.
({
	openVisualForcePage : function(component, event, helper) {
    var recordId = component.get("v.recordId");
	window.open('/apex/YOURVFPAGENAME?id=' + recordId);
	}
})


 
SFDC cloud  GuySFDC cloud Guy
shun Kosaka@ thanks you