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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

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

pgupta
1-Visitor

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

How to get the Jar files for

https://change.unigroupinc.com/documentation/javadocs/triggers/index.html

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.addSelection(actIssue);

  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) f.next();

  System.out.println(temp.getDisplayName()+":"+temp.getValueAsString());

  }

  System.out.println(i.getField("MKSIssueHistory").getDisplayName()+":"+i.getField("MKSIssueHistory").getValueAsString());

MKSIssueHistory:17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0

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 ???

3 REPLIES 3

Hi

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"));

        cmd.addSelection(issueID);

        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) li.next();

            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);

                le.add(extItem);

            }

        }

Hope this helps, questions are welcome!

Volker

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.

Volker

Announcements


Top Tags