Hello. Hoping some JS experts here on the forum can help with script for two very similar requests. I am trying to re-direct the user to different pages based on the an record ID in both scenarios.
1. Redirect based on SHIP_ID. If the ship is SHIP_ID # 53, redirect to page x, if the SHIP_ID is not #53, redirect to page y.
2. Redirect based on TOUR_SITE_ID. Tour sites 1, 2, 3, 4, 6 & 8 use one type of report (..../food-plan/..... and Tour Sites 5 & 7 use a different type of report (...../food-grid/.....). I have attempted the following without success:
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
if(" [@field:TOUR_SITE_ID] " = 1){
window.location = "https://www.myapp.com/system/food-plan/?RECORD_ID=[@field:RECORD_ID]";
}
else if (" [@field:TOUR_SITE_ID] " =2){
window.location = "https://www.myapp.com/system/food-plan/?RECORD_ID=[@field:RECORD_ID]";
}
else if (" [@field:TOUR_SITE_ID] " =3){
window.location = "https://www.myapp.com/system/food-plan/?RECORD_ID=[@field:RECORD_ID]";
}
else if (" [@field:TOUR_SITE_ID] " =4){
window.location = "https://www.myapp.com/system/food-plan/?RECORD_ID=[@field:RECORD_ID]";
}
else if (" [@field:TOUR_SITE_ID] " =6){
window.location = "https://www.myapp.com/system/food-plan/?RECORD_ID=[@field:RECORD_ID]";
}
else if (" [@field:TOUR_SITE_ID] " =8){
window.location = "https://www.myapp.com/system/food-plan/?RECORD_ID=[@field:RECORD_ID]";
}
else if (" [@field:TOUR_SITE_ID] " =5){
window.location = "https://www.myapp.com/system/food-grid/?RECORD_ID=[@field:RECORD_ID]";
}
else (" [@field:TOUR_SITE_ID] " =7){
window.location = "https://www.myapp.com/system/food-grid/?RECORD_ID=[@field:RECORD_ID]";
}
}
</script>