I need help. I have a visualforce page named "Edit Quote". I need a button to open this page on lightning. since javascript is not supported I created a button to open another vf page names “test_quote”, if javascript condition inside vf page “test quote” are met it should open “edit quote” page else an alert is displayed. Inside this page I put the javascript code.
test_quote:
<apex:page standardController="Opportunity" >
<script type = "text/javascript">
window.onload=function()
{
if('{!Opportunity.N_of_tasks__c}' > 0) {
alert('It is not possible to create a quote for this Opportunity since there are tasks associated');
window.history.back();
}
else if('{!Opportunity.No_Quotes__c}' == 1) {
alert ("It is not possible to create a quote in this process stage");
window.history.back();
}
else if('{!Opportunity.Opportunity_Channel__c}'== "Italy") && '{!Opportunity.Opportunity_Type__c}' == 'Professional Services' && '{!Opportunity.Technical_Feasibility__c}' == '') {
alert('It is not possible to create a quote for this Opportunity since must have a feasibility associated');
window.history.back();
else {
window.location.href = "/apex/0Q0/EditQuote?retURL={!Opportunity.Id}&oppid={!Opportunity.Id}&AccountId={!Opportunity.AccountId}"
}
};
</script>
</apex:page>
I don't know why but it doesn't work. No error on developer console. Only a rerender of the page. though I try only with this:
<apex:page standardController="Opportunity" >
<script type = "text/javascript">
window.onload=function()
{
if('{!Opportunity.N_of_tasks__c}' > 0) {
alert('It is not possible to create a quote for this Opportunity since there are tasks associated');
window.history.back();
}
};
</script>
</apex:page>
Can someone help me?
Thanks