Sync User Picker (single user) field

Originally asked by Samuel Carter on 18 May 2022 (original question)


I’ve been trying to get User Picker (single user) syncing successfully between two instances of Jira, and Jira Service Desk. This is a User Picker field, and both instances have the exact same users on each, and the same custom field ‘Responsible Guild’. Please see below for incoming/outgoing scripts:

Outgoing (JSM):

replica.customFields."Responsible Guild" = issue.customFields."Responsible Guild"

Incoming (Jira):

issue.customFields."Responsible Guild".value = replica.customFields."Responsible Guild"?.value.username

When this is run, we get an error on the incoming script ‘Cannot get property ‘username’ on null object’ and it cites this line:

issue.customFields."Responsible Guild".value = replica.customFields."Responsible Guild"?.value.username

Unsure on where I’m going wrong, or what I need to do to get this working.


Answer by Samuel Carter on 18 May 2022

Hi Andrii,

Thanks very much for your response, this worked perfectly!

Much appreciated.

Kind regards,

Sam


Answer by Andrii Markov on 18 May 2022

Hi Samuel Carter ,

Thank you for posting this question here.

Actually, accordingly to the following documentation article, I would suggest trying the following snippet:

issue.customFields."Responsible Guild".value = nodeHelper.getUserByFullName(replica.customFields."Responsible Guild".value.displayName)


Could you please try this out and get back to us with any outcome?

Kind Regards,
Andrii