# How to cancel/terminate the pending manual workitems

**URL:** <https://developer.sailpoint.com/discuss/t/how-to-cancel-terminate-the-pending-manual-workitems/17908>\
**Category:** IIQ Discussion and Questions\
**Tags:** identityiq, provisioning, workflows\
**Created:** [September 21, 2023, 7:53am UTC](https://developer.sailpoint.com/discuss/t/how-to-cancel-terminate-the-pending-manual-workitems/17908 "2023-09-21T07:53:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bellamkonda\_vb](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@bellamkonda\_vb](https://developer.sailpoint.com/discuss/u/bellamkonda_vb)\
**Post date:** [September 21, 2023, 7:53am UTC](https://developer.sailpoint.com/discuss/t/how-to-cancel-terminate-the-pending-manual-workitems/17908/1 "2023-09-21T07:53:21Z")

</div>

Hi All, we have an requirement that, when the user gets terminated at that time we need cancell all the pending access request to the user. Here, we are able to cancel the access reuest for automated apps but for disconnected apps it is getting generated manual workitem need to cancel that also.how can we acheive this, your inputs will be helpful. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![akash\_gupta](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/akash_gupta/32/2869_2.png) [@akash\_gupta](https://developer.sailpoint.com/discuss/u/akash_gupta)\
**Post date:** [September 21, 2023, 10:46am UTC](https://developer.sailpoint.com/discuss/t/how-to-cancel-terminate-the-pending-manual-workitems/17908/2 "2023-09-21T10:46:00Z")

</div>

You can try something like this from the leaver workflow -  
This code looks for all open approval and manual fulfilment workitems associated to the terminated user and close/cancel them out.

* * *

import java.util.List;  
import sailpoint.object._;  
import sailpoint.api._;  
import sailpoint.tools.\*;

Identity identity = context.getObjectByName(Identity.class, identityName);

if (null != identity) {

[//log.debug](https://log.debug)(“Starting query for workitems”);  
String idname = identity.getName();  
String desc = "Manual Changes requested for User: " +identity.getDisplayName();  
String desc2="Owner Approval - Account Changes for User: " +identity.getDisplayName();  
[//log.debug](https://log.debug)(“Description =” +desc);

Filter f1 = Filter.or(Filter.eq(“description”, desc), Filter.eq(“description”, desc2));  
QueryOptions ops = new QueryOptions();  
ops.addFilter(f1);  
List items=context.getObjects(WorkItem.class,ops);

if(!items.isEmpty()) {  
for (WorkItem item:items) {

```
 item.setState(WorkItem.State.Canceled);
 item.setCompleter("spadmin");
 item.setCompletionComments("Cancelled due to user termination");
 Workflower workflower = new Workflower(context);  
  workflower.process(item, false);

  context.decache(item);

```

}  
}

## } else { log.error("Remove WorkItem Step – identity is null "); }

Hope this is what you were looking for.

---

<div class="post-metadata">

**Author:** ![bellamkonda\_vb](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@bellamkonda\_vb](https://developer.sailpoint.com/discuss/u/bellamkonda_vb)\
**Post date:** [September 21, 2023, 11:35am UTC](https://developer.sailpoint.com/discuss/t/how-to-cancel-terminate-the-pending-manual-workitems/17908/3 "2023-09-21T11:35:16Z")

</div>

Hi @akash_gupta , thank you for the rule. let me try this, hopefully it will work.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [November 20, 2023, 11:35am UTC](https://developer.sailpoint.com/discuss/t/how-to-cancel-terminate-the-pending-manual-workitems/17908/4 "2023-11-20T11:35:21Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
