It's possible that JavaScript is not supported in ArcGIS Server (though I can't find any documentation to confirm that). Perhaps try changing the parser to Python and rewrite it. Here's what a more efficient version would look like in Python:
def FindLabel( [NPC_CATEGORY_ID] ):
npcId = [NPC_CATEGORY_ID]
idCodes = {
"231": "WPn53",
"371": "WMs83",
"372": "WMs92",
"375": "WPn53",
"376": "WPn53"
}
if npcId in idCodes:
return idCodes[npcId]
return npcId
or, here's what your original function looks like in Python without modification:
def FindLabel( [NPC_CATEGORY_ID] ):
idArray = ["231","371","372","375","376"]
codeArray = ["WPn53","WMs83","WMs92","WPn53","WPn53"]
labelValue = [NPC_CATEGORY_ID]
for i in range(len(idArray)):
if idArray == [NPC_CATEGORY_ID]:
labelValue = codeArray
return labelValue