Managed to find the solution to it.. Using the post function script on insight documentation and then just re-defining newValue in the example with newValue.getUsername().
def newValue = issue.getCustomFieldValue(jiraCustomField);
def user = newValue.getUsername(); //to be used in attribute bean