Stop Workflow of a Closed Record

Hello;

Many people have records those are closed automatically via automation tools like Omnibus, or escalations. And these records remain in workflow even they are closed. So there is a little piece of code which can resolve this problems..
First go to the database configuration and create a relationship called “ACTIVEWORKFLOW” which can get you active workflows on the record. An example of ticket should be like this:
Name: ACTIVEWORKFLOW
Child Object: WFINSTANCE
Where Clause: ownerid=:ticketuid and ownertable=:CLASS and active=1
Remarks: Gets the related active workflow instances

Now create the class and rebuild redeploy maximo.ear..
Now all you have to do is to create an escalation which runs every 10 minutes.(Or whatever you want) Make sure you have stated closed records in where clause.. (Write historyflag=1 for workorder or ticket objects)
And make it run…

Note: You can run this code for every object. Because the code is written for Mbo Object.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package custom.common.action;
 
import java.rmi.RemoteException;
 
import psdi.mbo.MboRemote;
import psdi.util.MXException;
import psdi.workflow.WFInstanceRemote;
import psdi.workflow.WFInstanceSetRemote;
 
public class stopWFonClosedRecords implements
psdi.common.action.ActionCustomClass {
 
public void applyCustomAction(MboRemote mbo, Object[] arg1)
throws MXException, RemoteException {
// TODO Auto-generated method stub
WFInstanceSetRemote wfInstanceSet=(WFInstanceSetRemote) mbo.getMboSet("ACTIVEWORKFLOW");
if(!wfInstanceSet.isEmpty()){
for(int i=0;i<wfInstanceSet.count();i++){
WFInstanceRemote wfInst=(WFInstanceRemote) wfInstanceSet.getMbo(i);
wfInst.stopWorkflow("Auto Stop");  // Memo of the transaction...
wfInstanceSet.save();
}
}
 
}
}

Leave a Reply