Can't find the document field for a WI

Description
DCwom
Posts: 37
Joined: Mon Sep 29, 2014 7:00 pm

Can't find the document field for a WI

Postby DCwom » Tue Jan 20, 2015 7:04 pm

I'm trying to find the document in which a work item resides. I've tried the getLocation() method which gives a long path, but that doesn't help. The getModuleURI () method looks promising but it won't run, I get a "Cannot find function" error. Any ideas of the best way to find the document in which a work item resides?
Dennis

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: Can't find the document field for a WI

Postby martins » Wed Jan 21, 2015 6:36 am

Hello Dennis,

because of historic reasons Polarion Documents are internally called "Modules".

Therefore you need the method "IWorkItem.getModule()" to get a "IModule" object, which represents the document where the WorkItem is located in.

IWorkItem.getModule().getModuleName() gives you the name of the document.
IWorkItem.getModule().getModuleFolder() gives you the name of the document's space and
IWorkItem.getModule().getModuleNameWithSpace() is a collocation of both - space and document name.

Kind regards

Martin

DCwom
Posts: 37
Joined: Mon Sep 29, 2014 7:00 pm

Re: Can't find the document field for a WI

Postby DCwom » Wed Jan 21, 2015 2:51 pm

martins wrote:Hello Dennis,

because of historic reasons Polarion Documents are internally called "Modules".

Therefore you need the method "IWorkItem.getModule()" to get a "IModule" object, which represents the document where the WorkItem is located in.

IWorkItem.getModule().getModuleName() gives you the name of the document.
IWorkItem.getModule().getModuleFolder() gives you the name of the document's space and
IWorkItem.getModule().getModuleNameWithSpace() is a collocation of both - space and document name.

Kind regards

Martin


Martin,
Thanks for the help, I can get the module name now.

I've got another question, with this module name how can I find a list of all the WIs in this module? I've tried the getModuleWorkItemUris() function but it generates syntax errors that I can't seem to solve, do I need to use a query instead, something like queryWorkItems()? I can't get the query syntax to work either so I'm a bit lost at the moment.

Dennis

DCwom
Posts: 37
Joined: Mon Sep 29, 2014 7:00 pm

Re: Can't find the document field for a WI

Postby DCwom » Wed Jan 21, 2015 7:03 pm

I think I've solved my own question. I'm able to use the following function to get the list of WIs in the module.

Code: Select all

var allWI = workItem.getModule().getAllWorkItems();

But I still can't retrieve the individual WIs. What I want to do is access each WI in the list of returned WIs and add an approver to it, here is that code, but the getWorkItemById function won't work, all I get are syntax errors.

Code: Select all

var projID = workItem.getProject().getId();
var allWI = workItem.getModule().getAllWorkItems();
var iter = allWI.iterator();         // Unload the list of WI & get their IDs
while (iter.hasNext()) {
    var docWI = iter.next();
    var ZZ = docWI.getId();
    var individualWI = trackerService.getWorkItemById(projID, ZZ);
    individualWI.addApprovee("Dennis");.
.
.
}

Any ideas of what I'm doing wrong here? The getWorkItemById() function is a method of the trackerservice but it doesn't work for me.

Dennis

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: Can't find the document field for a WI

Postby martins » Thu Jan 22, 2015 9:09 am

Hello Dennis,

getWorkItemById() is a function in the TrackerWebService! By looking at your code I assume you are not using the Webservice interface. Therefore you can't use functions from the TrackerWebService.

You have to use the ITrackerService class. There's a method getWorkItem(java.lang.String projectId, java.lang.String workItemId) which is the equivalent to the getWorkItemById(...) from the TrackerWebService.

But indeed you don't need this method. Your "docWI" already is an object of type IWorkItem for which you can call method "addAprovee(...)".

Kind regards

Martin

DCwom
Posts: 37
Joined: Mon Sep 29, 2014 7:00 pm

Re: Can't find the document field for a WI

Postby DCwom » Thu Jan 22, 2015 6:02 pm

martins wrote:Hello Dennis,
But indeed you don't need this method. Your "docWI" already is an object of type IWorkItem for which you can call method "addAprovee(...)".


Martin,
Thanks again for the help, I had tried the IWorkItem type earlier, but now I see why it didn't work for me the 1st time. There is a difference in the spelling of the addAprovee functions in the TrackerWeb & ITracker. The TrackerWeb uses addApprovee while the ITracker uses addAprovee, I was using 2 "p"s in my method call.
Dennis


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: Antoniovxj, Google [Bot] and 31 guests