Opened 7 years ago

# Using set_owner_to_previous in case reporter and owner are the same

Reported by: Owned by: anonymous Eli Carter normal AdvancedTicketWorkflowPlugin normal Patrick Schaaf 0.11

### Description

I'm using

set_owner_to_reporter when resolving a ticket, so the reporter has to confirm the resolved ticket. On confirmation the ticket is closed where I'm using set_owner_to_previous in order to close the ticket and to have as owner the one who has resolved the ticket (statistics). In case that somebody reported a ticket to himself the set_owner_to_previous will set the owner empty, as it seems that there were no previous owner as all the time reporter and resolving owner were the same.

Can you please change the set_owner_to_previous to keep the current owner in case there is no previous owner???

### comment:1 Changed 7 years ago by anonymous

Sorry, the idea is wrong, as there is still the possiblity that the ticket was previously reassigned.

Is it possible somehow to get the previous state owner???

### comment:2 Changed 7 years ago by anonymous

I have a workaround for now:

Adding a custom field which is filled with resolver name when resolving. On closing of ticket the owner is set to value of this field.

### comment:3 Changed 7 years ago by anonymous

Sorry there is no way to set a custom field to any value automatically, so it would be great if you could introduce such an operation.

### Changed 6 years ago by anonymous

previous owner patch

### comment:4 Changed 6 years ago by anonymous

I came across this one when a ticket was assigned an owner at creation, therefore ticket_change entry was not created to change the "owner" from the reporter. Assuming that because the ticket has no previous owner because the has been no ticket_change entry in the database is wrong. I would consider this a defect not an enhancement.

I've attached a patch that if there is no owner change and there is a current owner then it sets the new owner to current owner, otherwise it deletes the owner.

### comment:5 Changed 6 years ago by anonymous

Sorry the patch did not attach correctly, below is the change

Left file: C:\Apps\Python25\Lib\site-packages\advancedworkflow\controller.py.orig
198c198,205
<             owner = ''
---
>             # Check to see if the ticket has a current owner
>             cursor.execute("SELECT owner FROM ticket WHERE id=%s " \
>                             , (ticket.id, ))
>             row = cursor.fetchone()
>             if row: # Set new owner to current owner
>                 owner = row[0]
>             else: # There has never been an owner
>                 owner = ''


### comment:6 Changed 6 years ago by Eli Carter

Resolution: → fixed new → closed

In [9962] I made it fall back to the current owner if there was never a previous setting for the owner. If the previous value of owner was in fact empty, then set_owner_to_previous will still delete the owner. There is a more fundamental issue that if a previous action "set" the owner to the same user as the ticket was already owned by, and the next action is set_owner_to_previous, the owner will be changed to whatever user had it before the current one, which may not be what was desired. I don't see a good answer for that situation; perhaps an implementation of set_owner_to_previous_state_owner would be more robust, but I think that would have odd edge cases as well.

### comment:7 Changed 6 years ago by Patrick Schaaf

Cc: Patrick Schaaf added; anonymous removed fixed closed → reopened

While [9962] fixed the case (in 0.12...) where the ticket started out at creation time with an owner set, and never had a change later, it does not fix the case where the ticket started out unowned and was then accepted exactly once.

In that case, there is a single ticket_change record with oldvalue the empty string.

I will append a patch that handles this situation, by always using ticket[owner] when the database lookup did not find a nonempty oldvalue. The patch also will bring the 0.11 code in line with the 0.12 change.