Painscript Script - cast String as Int?

We have a mapping issue that will be addressed soon for a field that should be an int but is presently a string. All values in the index should cast cleanly.

Anyhow, in a pinch I wanted to aggregate some data on the field and thought creating a scripted field in K5 would be a temp solution. Can anyone point me in the right direction or provide a code example? I tried several things including (int)['doc.myfield'].value and also parseInt(string) as documented at https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#parseInt%2Djava.lang.String%2D.

Is type casting a String to Int supported in either of the 3 scripting languages listed in K5?

Hi Steve,

Try:

Integer.parseInt(doc['myfield'].value)

Thanks

That worked like a champ - thanks Chris!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.