You need to sign in to do that
Don't have an account?
rk
Add click on Javascript Button to Visualforce Page.
Hi.. I am new and learning salesforce. I wanted to create a custom Button in lightning.Upon clicking,they need to validate a field and only if true it has to open a visualforce page. I am able to do this using onclick javascript button,but i need it in lightning. I have added my javascript and visualforce page. Please guide me in this.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var type = "{!Opportunity.Type}";
if(type === 'Existing Customer - Downgrade'){
window.open('/apex/OppRenewal'); //to reload the window and show the updated values
}else{
alert('Your not allowed.');
}
Visualforce Page Code
<apex:page standardController="Opportunity" showHeader="true" standardStylesheets="true" sidebar="true">
<apex:form id="mainform">
<apex:pageMessages id="msgs"/>
<apex:pageblock title="Quote Renewal">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information" >
<apex:outputfield value="{! Opportunity.name}"/>
<apex:outputfield value="{! Opportunity.Type}"/>
<apex:outputfield value="{! Opportunity.Amount}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contacts">
<apex:inputField value="{! Opportunity.Bill_to__c}" label="Bill TO"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
I tried to add the <script> but I am not able to achive it.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var type = "{!Opportunity.Type}";
if(type === 'Existing Customer - Downgrade'){
window.open('/apex/OppRenewal'); //to reload the window and show the updated values
}else{
alert('Your not allowed.');
}
Visualforce Page Code
<apex:page standardController="Opportunity" showHeader="true" standardStylesheets="true" sidebar="true">
<apex:form id="mainform">
<apex:pageMessages id="msgs"/>
<apex:pageblock title="Quote Renewal">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information" >
<apex:outputfield value="{! Opportunity.name}"/>
<apex:outputfield value="{! Opportunity.Type}"/>
<apex:outputfield value="{! Opportunity.Amount}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contacts">
<apex:inputField value="{! Opportunity.Bill_to__c}" label="Bill TO"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
I tried to add the <script> but I am not able to achive it.
For you solution you neeed to create HeadLess quick action:-
headlessQuickAction.html headlessQuickAction.js
headlessQuickAction.js-meta.xml
OpportunityController.cls
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Yes, we create by VF page
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh