Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request]: Complete-PSWorkItem include original task id with archived task #7

Closed
jbelina opened this issue Jan 2, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request pending feedback

Comments

@jbelina
Copy link
Contributor

jbelina commented Jan 2, 2023

Describe the request

I ended up using the following in my own wrapper for Complete-PSWorkItem so that I could see both the new and old Task ID's when closing a task.

if ($ID) { "Completing Task(s)" | Write-Verbose $completed_tasks = { foreach ($taskid in $ID) { "Complete Task: $taskid" | Write-Debug Complete-PSWorkItem -ID $taskid @parameters | Select-Object -Property @{Name = 'OriginalTaskID'; Expression = { "$taskid" } }, Name, Description, Category, CompletedDate, @{Name = 'ClosedTaskID'; Expression = { "$($PSItem.ID)" } } } }

PowerShell version

7.2

Platform

Windows 11 Home

@jbelina jbelina added the enhancement New feature or request label Jan 2, 2023
@jdhitsolutions
Copy link
Owner

This makes sense and is something I should have looked at harder when I started this. Currently, I'm using the ID as the key for the table. I'd have to restructure the archive table, which would be a breaking change. This will take some time to work out.

@jdhitsolutions
Copy link
Owner

One thing I could do that wouldn't be that hard is to add a property to the PSWorkItemArchive object to store the original ID. I can modify the format file to display it instead of the table ID. I can also add a parameter set to Get-PSWorkItemArchive to get the item by its original ID.

The biggest issue would be updating the database and table structure.

@jbelina
Copy link
Contributor Author

jbelina commented Jan 2, 2023

I like that idea.

For now it's not really something I need, it's just nice to see when I'm choosing a task.

So, my wrapper works perfectly for me.

@jdhitsolutions
Copy link
Owner

I've been trying a few things, and maybe writing things out will help clarify the situation. The task object has a hidden property called taskID which is a GUID. The ID number of a PSWorkItem is the row number from the tasks table. When a task is completed, it is copied to the Archive table. At this point, when I get a completed task the ID number is a different row number because it is a different table.

I've been testing code where the archive table has an additional column called OriginalID. When a task is closed, I copy the original task id, i.e. the original row number, to this column.

The problem is that when I create a new task, it will have a row number identical to the last completed item. This means when I get completed items, I will have duplicate items with the same original id. To me, this makes this new table column meaningless. Getting a completed item by its original ID could return multiple entries.

I wonder if I could create a new PSWorkitem property and table column called tasknumber. I could use the rownumber for the value on new items. This property could be inherited by archived items. This would also require table updates. This has possibilities.

@jdhitsolutions
Copy link
Owner

The code I have now that seems to work copies the original ID to the ID for the archived item. I think I have this working in the current release.

@jdhitsolutions
Copy link
Owner

I think I have this resolved. If not, we can re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pending feedback
Projects
None yet
Development

No branches or pull requests

2 participants