Welcome to KORG, Mark!

Actually
 Code:
$UserName = Left(@USERID, 8)
is all you need. Left() will not return an error if you request more than the number of characters in the string. It will simply return the entire string.

If you use/allow spaces in usernames in your environment, you might need to replace them to make your other task work properly. Not everything works with spaces.

Something like
 Code:
$UserName = Join(Split(Left(@USERID, 8), ' '), '_')
This takes the first 8 chars of the username and replaces any spaces with underscores. If the ID is less than 8, then the entire userID is used (and spaces replaced).

Glenn
_________________________
Actually I am a Rocket Scientist! \:D