I don't see why it wouldn't work.
It's probably just a typo in your post here, but your script step sets a value to $$CodesCount and your next sentence refers to $$CodeCount-- a variable with a name that's one letter different...
I have captured the screen with a script debugging and data viewer. you will notice that the variables $s1 and $codescount are not carriying any values
are two different variables.
Not that this really matters here, but it's a detail to watch out for as you work with this script. Clearly, an empty list was returned by the valueListItems function. I'm a bit concerned about the "Reports" parameter. I'm thinking it should be "Reports.fp7" as this should be the name of your file here.
I routinely use valuelistItems ( Get ( FileName ) ;
as both a way to get the syntax right and as a way to make sure this function continues to work even if I change the file name.
I corrected the typo but I am still getting the same result
note the difference in the data viewer between $$codescount and word count above it and between $s1 and middlewords above it
Please try it with Get (Filename) instead of "reports" and see if anything changes.
I did that... if you notice in the previous post I have one with get(filename) and one with "repors"
It did not really matter
Apologies, I didn't read as carefully as I should. Having taken that careful look, I spot another typo. You have " service codes" as the name of your value list where it looks like you should have "service codes". (note leading space.)
I removed the space and it worked ... I apologize for wasting your time next time I will be very careful before I send you anything
No time wasted on my part.
When I do this, I always use get (filename). Then I can change my file name and not have this function fail. Then I open manage value lists and copy the value list name from there for pasting into this calculation. I do this in a number of areas when scripting and developing calculations to make sure I get the text exactly the same. Referencing a variable is another case where I use this method...