Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to get complete history of the issue using mks api??


How to get complete history of the issue using mks api??

How to get the Jar files for

How can we get the complete history with all modifications done in a particular field for a particular issue using java api of MKS ?

Command issuehistory = new Command(Command.IM, "viewissue");


  issuehistory.addOption(new Option("showHistory"));

Response response = cmdRunner.execute(issuehistory);

Iterator f = response.getWorkItem(actIssue).getFields();

  WorkItem i = response.getWorkItem(actIssue);

  while ((f).hasNext())


  Field temp = (Field);





But i cannot get the whole history i.e who modified the issue on what date what all fields were changed from this response ???

Does anybody have any idea how to do it ???



the command I am using to create an audit trail is this. Its part of my own Custom Extension for the Gateway:

        String issueID = target.getExternalId();

        List<ExternalItem> le = new ArrayList<>();

        Command cmd = new Command(Command.IM, "viewissue");

        cmd.addOption(new Option("showHistory"));


        Response result = imSession.executeCmd(cmd);

        // ResponseUtil.printResponse(result, 1, System.out);

        WorkItem wi = result.getWorkItem(issueID);

        target.getItemData().addField("Summary", wi.getField("Summary").getValueAsString());

        target.getItemData().addField("Type", wi.getField("Type").getValueAsString());

        target.getItemData().addField("ID", issueID);

        ListIterator li = wi.getField("MKSIssueHistory").getList().listIterator();

        while (li.hasNext()) {

            Item item = (Item);

            HistoryItem hi = new HistoryItem(item);

            // log("hi.getChangedFieldMap().size(): " + hi.getChangedFieldMap().size(), 2);

            for (String key : hi.getChangedFieldMap().keySet()) {

                ExternalItem extItem = new ExternalItem("ISSUE", issueID + (counter));

                extItem.setInternalId(issueID + counter++);

                extItem.add("Type", "Audit Entry");

                if (item.getId().contentEquals("0")) {

                    extItem.add("Operation", "Creation");

                } else {

                    extItem.add("Operation", "Modification");


                extItem.add("Modified By", hi.getModifiedBy());

                extItem.add("Modified Date", hi.getModifiedDate());

                extItem.add("Changed Field", key);

                extItem.add("Changed Value", hi.getChangedFieldMap().get(key));

                // target.addChild(extItem);




Hope this helps, questions are welcome!


The following items are not part of the MKS api
1. HistoryItem hi = new HistoryItem(item);
2. String issueID = target.getExternalId()     List<ExternalItem> le = new ArrayList<>();
3. ExternalItem extItem = new ExternalItem("ISSUE", issueID + (counter));

how did u implement them ?? If u implemented them using any other API Can u provide the jar file ?

Hi Pritha,

sorry to confuse you. This code part is from one of my own gateway extensions.

It was my intension just to show you how you can get the details, without sending you ready to use code.

But, apart from the ExternalItem, which is Gateway specific, all the other code shall be takeable and moveable into your own code.

If you are interested in how to do it exactly we would have to set up a web session, it's not that easy to explain it here in the forum.


Top Tags