Please help me find the error in my code. I am trying to generate a link in a popup based on certain criteria for the address. I got it to work for one specific case but when I try the if else the code won't run.
if(($feature.STR_TYPE == "AV") && ($feature.PRE_DIR != NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20ave%20"+$feature.PRE_DIR+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20ave%20"+$feature.PRE_DIR;}
else if (($feature.STR_TYPE == "AV") && ($feature.PRE_DIR = NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20ave"+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20ave";}
else if (($feature.STR_TYPE != "AV") && ($feature.PRE_DIR != NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20+"+$feature.PRE_TYPE+"%20"+$feature.PRE_DIR+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20"$feature.PRE_TYPE+"%20"+$feature.PRE_DIR;}
else if (($feature.STR_TYPE != "AV") && ($feature.PRE_DIR = NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20+"+$feature.PRE_TYPE+"%20"+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20"$feature.PRE_TYPE+;}
Solved! Go to Solution.
You were missing a extra "=" on line 3
$feature.PRE_DIR == NULL
if(($feature.STR_TYPE == "AV") && ($feature.PRE_DIR != NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20ave%20"+$feature.PRE_DIR+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20ave%20"+$feature.PRE_DIR;}
else if (($feature.STR_TYPE == "AV") && ($feature.PRE_DIR == NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20ave"+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20ave";}
else if (($feature.STR_TYPE != "AV") && ($feature.PRE_DIR != NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20+"+$feature.PRE_TYPE+"%20"+$feature.PRE_DIR+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20"$feature.PRE_TYPE+"%20"+$feature.PRE_DIR;}
else if (($feature.STR_TYPE != "AV") && ($feature.PRE_DIR = NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20+"+$feature.PRE_TYPE+"%20"+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20"$feature.PRE_TYPE+;}
When posting code, please us the "Insert/Edit code sample" button. It's much easier to read and analyze rather that trying to replicate it from an image
It also helps to post the specific error message rather than saying "the code won't run."
Although ArcGIS Arcade looks like JavaScript, it isn't JavaScript. There is no "else if" construct in Arcade, refer to If - else | ArcGIS Arcade | Esri Developer.
Additionally, there is almost always a better logical construct/function than using large if/else blocks. I encourage you to explore using When.
You can use "else if" in a if/else block, but I do agree that using When is a better solution.
Thank you both, I fixed the error and will try to use When instead!
Ken, interesting, their documentation implies it isn't supported since they fully nest a single if/else statement within the else portion of another statement instead of using "else if" directly. I know there are certain common JavaScript constructs that Arcade doesn't support, I just thought "else if" was another.
You were missing a extra "=" on line 3
$feature.PRE_DIR == NULL
if(($feature.STR_TYPE == "AV") && ($feature.PRE_DIR != NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20ave%20"+$feature.PRE_DIR+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20ave%20"+$feature.PRE_DIR;}
else if (($feature.STR_TYPE == "AV") && ($feature.PRE_DIR == NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20ave"+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20ave";}
else if (($feature.STR_TYPE != "AV") && ($feature.PRE_DIR != NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20+"+$feature.PRE_TYPE+"%20"+$feature.PRE_DIR+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20"$feature.PRE_TYPE+"%20"+$feature.PRE_DIR;}
else if (($feature.STR_TYPE != "AV") && ($feature.PRE_DIR = NULL)){
return "http://fileshare.napoleonohio.com/vfolder_frame.ghp?vfolder=/Address%20Files/"+$feature.STR_NAME+"%20+"+$feature.PRE_TYPE+"%20"+"/"+$feature.STR_NUM+"%20"+$feature.STR_NAME+"%20"$feature.PRE_TYPE+;}