It's all about the answers!

Ask a question

How to set the values programmatically which is non-editable from the process configuration


Arjun Pande (3212) | asked Jul 28 '15, 1:38 a.m.
edited Jul 28 '15, 2:33 a.m. by Ralph Schoon (56.2k23642)

Hi,

I am planning to set a value programmatically in an attribute each time I save the work item. i am facing some issues while setting a value to an  attribute as that attribute is read-only field(which is done by process configuration manually). Below is the code to set the value of an attribute.

public void setCustomStringAttributeById(String attrId, String ac)
   throws InvalidAttributeIdException {

  IAttribute attr = customAttributes.get(attrId);
  if (attr == null) {
   throw new InvalidAttributeIdException("No attribute with ID["
     + attrId + "] found.");
  }

  workItem.setValue(attr, ac);
 }

ac is the value which we want to set(it may be hard coded).

It is giving me below error while saving the work item

Problem
The 'Feedback' attribute is not modifiable .

Please let me know what I am missing . Thanks in advance


Comments
Donald Nong commented Jul 28 '15, 2:02 a.m.

The code is irrelevant. Why do you think you should be able to set value for a read-only field?

One answer



permanent link
Ralph Schoon (56.2k23642) | answered Jul 28 '15, 2:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can, in principle, set a read only attribute using the API. I just did that. Also attribute customization allows to set read-only values.

I don't know if you can do this in each context though. Try to make it not read only. If it works then, it might be impossible in your context - if it still does not work then there is a different problem. If the error message is accurate I have no idea, otherwise show the real error message.

Please note, there are attributes that you can not modify e.g. modified date and id.

Comments
Ralph Schoon commented Jul 28 '15, 3:16 a.m. | edited Jul 28 '15, 3:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I have to correct myself. I just forgot to save the process change. I am not able to modify the read only attribute using a Java Client. I see

CRRTC0299E: The work item with the ID 93 cannot be saved because an attempt was made to change the attributes '[Custom Boolean]' which are not modifiable.

You would have to leave the attribute as writable and make it read only in the editor presentation, I think.

Your answer


Register or to post your answer.