How to Modify SD.CloseIncidents to Work with Subtasks?
The SD.CloseIncidents that comes with ServiceDesk 7.1 SP2 does not work with Incidents that have subtasks. Incident datatype only includes one of the TaskIDs and only one task will be closed. This will also mess up the incident a bit.
The project can be modified to include a loop through all the tasks that are part of this process and send a closing message to each of these. The approach is rather brute force one, as it does put messages in the queue for all the tasks that were in the incident, including closed ones. However, Workflow does seem to properly clean it up afterwards either way, based on my quick testing.
This is only one way of achieving this, I do not claim it to be the best or most efficient way.
All the usual disclaimer things apply:
- Don't do this in your production ServiceDesk before testing it.
- Consider this an idea or example.
- It is a customization and is not supported.
Customize the SD.CloseIncidents project:
- Go to 'Model : Action Model'
- Add a 'Get Task Assignments For Process' component after 'Create Close Message (3.9)' (and before 'Close Incidents (3.6)') with these settings:
- Uncheck Use Current Process
- Tracking ID: Incident.Tracking_id
- Add a 'For Each Element in Collection' component after that with these settings:
- Array Variable Type: LogicBase.Core.Ensemble.WorkflowTasks.TaskAssignment
- Array Variable Name: resultTaskAssignments
- Item Output Variable Name: tItem
- Connect the 'next element' path from 'For Each Element In Collection' to 'Close Incidents (3.6)'.
- Connect the outbound path from 'Create Log Entry (3.3)' to 'For Each Element In Collection'.
- Connect the 'finished' path from 'For Each Element In Collection' to 'For Each Incident In Selection (3.5)'.
- Modify the 'Close Incidents (3.6)' component:
- Task ID: tItem.TaskID
- Optional: Modify the 'Create Log Entry (3.3)' component
- Log Entry Level: Error
- Log Entry Text: Closing Message has been sent to the following incident task ID: [tItem.TaskID] (assigned to [tItem.ReferenceName])
I would keep the log entry in step 8 at Error level and an assignee name in there just so you will be able to keep an eye on what tasks get affected. After some testing when you're sure this works, change its level back to Warn.
Screenshot of the resulting workflow is attached.