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
MikeMikeMikeMike 

Need assistance with an S-Control that can branch to 2 separeat URL's based on a test

Here's my situation, I have a Custom button that points to and runs an executable and returns a value in a separate window.  It currently is listed as Content Source: URL a lists a single URL.
 
I need to make the process conditional.  I would like to test whether a field is populated.  If it is not, the existing URL process is valid.  I created a URL pointing to '.txt' file with an Error Message and would like to display message if the field to be tested has a value. 
 
 
I changed the Content Source of the button from URL to OnClick JavaScript.   After several attempts, here's what I have:
 
<script type="text/javascript">
//determine if a license key already exists
IF ISNULL( Asset.Station_License_Key__c )
// NO - go ahead and create one
{
"http://zugiis01/LicenseEXE/lgen.dll?ID={!Asset.Id}&USER={!User.Email}"
}
ELSE
// ALREADY EXISTS - display "no-go" message
{
"http://zugiis01/_index.php3?path=/MR_test"
}
</script>
 
This gives me a vague message, something about mixing scripts.
 
Please help.  Thanks in advance,
 
werewolfwerewolf
You're mixing Javascript and formula field syntax here.  You need pure Javascript in Scontrols, so:

if ('{!Asset.Station_License_Key__c}'=='') {
 // go to one URL
 location.replace('URL here');
} else {
 // go to the other URL
 location.replace('other URL here');
}
MikeMikeMikeMike
Tried what you suggested (code below) and received the following message:
     Cross-site Scripting
     Possible cross site scripting attempt detected.
 
Here's my code:
<script type="text/javascript">

//determine if a license key already exists
// IF ISNULL( Asset.Station_License_Key__c )
// NO - go ahead and create one
// {
// "http://zugiis01/LicenseEXE/lgen.dll?ID={!Asset.Id}&USER={!User.Email}"
// }
//ELSE
// ALREADY EXISTS - display "no-go" message
// {
// http://zugiis01/_index.php3?path=/MR_test
I left in, but commented out, what was there initially.  Was this wrong?  Should I have commented out the 1st line as well?
//determine if a license key already exists
}
if ('{!Asset.Station_License_Key__c}'=='') {

// go to one URL

location.replace('http://zugiis01/LicenseEXE/lgen.dll?ID={!Asset.Id}&USER={!User.Email}');
}
else
// go to the other URL
{
location.replace('http://zugiis01/_index.php3?path=/MR_test');
}
I appreciate any help you can provide.  Thanks,  Mike