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
tocktock 

Java Novice - stuck on 'if stament'

Hello,
 
I have this bit of java i wrote, for an s-control, however the if (stage == 'Needs Analysis') isn't going through when i know it should as the value of stage is definitely 'Needs Analysis'. The {!Opportunity.StageName} value is coming from a selection box, ifthis makes a difference. any ideas or blatent mistakes here?
 
 
I also know the {location = "http://webaddress.com}";} works fine.
 
<html>
<script>
var stage = {!Opportunity.StageName}
 
if (stage == 'Needs Analysis')
{location = "http://webaddress.com}";}

</script>
</html>
 
 
Execute EZSAASExecute EZSAAS

Common oversight, you need quotes for variable assignment and semicolon at the end of every line in JavaScript. Code corrected is included.
Code:
<html>

<script>
var stage = "{!Opportunity.StageName}";
 
if (stage == 'Needs Analysis')
{location = "http://webaddress.com}";}

</script>
</html>
tocktock
That's great, Thanks!