When Assignee = Unassigned sync fails on null value

Originally asked by Jonathan on 05 November 2021 (original question)


Creation of a new task sets assignee as ‘Unassigned’
Ideally staff would set a user but at creation a user is not always decided on.

Problem arises when trying to exalate one of these tasks.

Prior to this situation coming up I was simply using

//outgoing sync this side
replica.assignee.displayName = issue.assignee.displayName

//incoming sync on other side
issue.customFields."Remote Assignee".value = replica.assignee.displayName 

Error Detail Message:

Cannot get property ‘displayName’ on null object
Error line: 18

//outgoing sync this side
replica.assignee.displayName = issue.assignee?.displayName ?: "Unassigned"

To try and solve I believe this should work as something very similar worked under visual mode.

Note: I am only passing the displayName as the user is not on the replica instance and is simply displayed on a custom field.


Comments:

Ariel Aguilar commented on 05 November 2021

You can try to do instead:

//outgoing sync this side
replica.assignee = issue.assignee?.displayName ?: "Unassigned"

Kind regards,

Ariel

Jonathan commented on 06 November 2021

Thanks for the suggestion, Unfortunately that just results in error:

Cannot cast object ‘Unassigned’ with class ‘java.lang.String’ to class ‘com.exalate.api.domain.hubobject.v1_2.IHubUser’

Ariel Aguilar commented on 08 November 2021

If you just do:

replica.assignee = issue.assignee

What are you trying to achieve here?

Kind regards,

Ariel

Jonathan commented on 09 November 2021

This doesn’t work as the users are not available on both sides. When we were using the visual method of connection to get around this I would set a custom text field to indicate the Reporter and Assignee.

as shown here

I didn’t think this should be hard to do but am quite stuck (old community)

The elvis operator ‘?:’ was working under visual so its odd it wont work here.

Ariel Aguilar commented on 23 November 2021

Is the remote assignee correct?

issue.customFields."Remote Assignee".value = replica.assignee?.displayName 

Maybe it should be replaced to:

issue.customFields."SA assignee".value = replica.assignee?.displayName