advanced label expression in Arcgis server doesn't label

Discussion created by sondickerson on Feb 11, 2013
Latest reply on Aug 30, 2013 by svenneglenne
I'd like to use the following advanced label expression for a layer in a map service.  This javascript function works in arcmap, but does not label the features when its published as a map service.  In the publishing preview window the labels do appear, but not in the finished service. 

function FindLabel ( [NPC_CATEGORY_ID] )

var labelValue = [NPC_CATEGORY_ID];

for (var i=0,l=idArray.length; i<l; i++)
   if  (idArray[i] ==  [NPC_CATEGORY_ID] ){
     labelValue = codeArray[i];

return labelValue;


Although, it doesn't present a solution that I could use, the following thread is similar:

If you have any thoughts on this one, please let me know.
Thanks greatly,