Computed Tag not working ("Script result didn't match expected output type INT64")

Pretty easy task, yet I am stuck…

I have 2 tags from the NodeRED data store:

and want to compute the absolute value of the difference between the green and the blue using a Computed Tag:

Resulting error in groov View is:

FWIW, I did not populate any of the Bit Index fields on any screen. Both input1 and input2 are integers.

Change your script to just:

return Math.abs(input1 - input2);

Your script gets wrapped in an implicit function; that’s what the function evaluateTag(input1, input2) { and } blocks are above and below the text editor. The script you have defined here is defining an inner function and not returning anything, which is why you get an Undefined out of it.

1 Like

Thank you @Jonathan_Fischer

That was (embarrassingly) my first time creating a Computed Tag in groov View. I see many more possibilities & opportunities here.

Works great now!