I have a table within my geodatabase with a list of Street IDs and Street Names. I then have a calculation rule where in my address layer I have the end user fill out the streetID and it automatically copies the Street Name out of the table and puts it in the Street Name field of the layer. This rules is then adjusted a few times in additional attribute rules to pull the street type and directional also from the table. I have this working as needed. However I wanted to add a message that pops up that when the user puts in a StreetID that doesn't exist it gives them a message instead of just doing nothing. So I added the else if statement at the end of my existing code (shown below) and now I get the error message no mater if I enter a valid ID number or Not instead of just getting it when it is not a valid ID number.
var street = FeatureSetByName($datastore, 'tStreet', ['Street_ID','St_Name'],false);
var SID = $feature.St_ID;
for(var i in street)
if(i.Street_ID == SID)
return i.St_Name
else if (i.Street_ID != SID)
return {"errorMessage": "Street ID does not exist"}