I have this custom button that is working
var cw = window.open('/apex/CreateSample?scontrolCaching=1&id={!Servicio__c.Id}', 'Crear Muestra', "height=450,width=600");
(function detectUnload() {
window.setTimeout(function(){
if (cw == null || cw.closed) {
window.location.reload();
return;
}
detectUnload();
}, 100);
})();
But I what only to do that if a State equals Complete. So I wrote this
if ({!Servicio__c.State__c}== "Complete")
{
(var cw = window.open('/apex/CreateSample?scontrolCaching=1&id={!Servicio__c.Id}', 'Crear Muestra', "height=450,width=600");
(function detectUnload() {
window.setTimeout(function(){
if (cw == null || cw.closed) {
window.location.reload();
return;
}
detectUnload();
}, 100);
})();)
}
else
{
alert("You can not do this");
}
Does anyone now why is not working? The error is "unexpected identifier" Thanks you in advance!