Convert integers to strings before using substring

When a field value is an integer, substring fails and crashes the process.
A call to `toString()` will convert the integer to a string, and let the substring pass.