Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Programatically making an attribute of workitem Read-only

Hi all

I want that one of the attributes of workitem should be editable only when the workitem is in New and In Progress state. Once it goes to Resolve state it should no longer be editable. If someone wants to edit it he has to come back to In Progress or New state. How this can be made possible ? ( I want to do this through a precondition. Precondition will check while changing the state of workitem to Resolve state, that if that attribute has any value defined in it. If not then it will stop the save action. If value is defined then it will make the field non-editable.)

Thanks
-Ankur

0 votes



One answer

Permanent link
Hi,

Look at this wiki page for info on adding new preconditions.

https://jazz.net/wiki/bin/view/Main/TeamProcessDeveloperGuide#Adding_New_Operation_Advisors

The following code should get you started with the problem you described above. Note the stringIdentifier of the work item's state may not be as I have put here - you should look this up in your process configuration.


public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

Object data= operation.getOperationData();
if (!(data instanceof ISaveParameter))
return;

ISaveParameter saveParameter= (ISaveParameter) data;
if (saveParameter.getNewState() instanceof IWorkItem) {
IWorkItem workItem = (IWorkItem)saveParameter.getNewState();
if (workItem.getState2().getStringIdentifier().equals("new") || workItem.getState2().getStringIdentifier().equals("in_progress")) {
IWorkItem oldWorkItem = (IWorkItem)saveParameter.getOldState();
// use one of the IWorkItem.get...() methods to compare
// the values of the attributes in new and old states
// if it is different, do this:
String summary = "Attribute not editable";
String description = "This attribute is not editable unless the work item is in state 'New' or 'In Progress'";
IAdvisorInfo info= collector.createProblemInfo(summary, description, ID);
info.setProblemObject(workItem.getItemHandle());
collector.addInfo(info);
return;
}
}
}


Thanks,

Simon

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: Jul 16 '09, 6:37 a.m.

Question was seen: 5,228 times

Last updated: Jul 16 '09, 6:37 a.m.

Confirmation Cancel Confirm