I am trying to call the JS method "returnToProposal" from an IF loop. Not sure what I am doing wrong here. I am getting the error
Error: Unknown function returnToProposal. Check spelling
Code: VF:
<apex:commandLink action="{!returnToQuote}" value="{!IF(riskRec.size>0 ,riskRec[0].Name,'')}" rendered="{!AND(!displayCartButton,isOppStageStageW == FALSE)}" rerender="theForm,pgMsgs" status="counterStatus" oncomplete="{!IF(riskRec.size > 0,returnToProposal('riskRec[0].id','closeTabFlag}'),'')}" id="theCommandLink1"/>
JS:
function returnToProposal(id,closeFlag){
if(closeFlag == 'true'){
window.open('/'+id,'_self');
}
}
What works:
oncomplete="returnToProposal('{!riskRec[0].id}','{!closeTabFlag}');"
But it gives error when riskRec list is empty
Subscript is invalid because list is empty
Error is in expression
returnToProposal('{!riskRec[0].id}','{!closeTabFlag}');' in component <apex:commandLink> in page wctaxanalysis_v2
What I need:
oncomplete="{!IF(riskRec.size > 0,returnToProposal('riskRec[0].id','closeTabFlag}'),'')}"