It's all about the answers!

Ask a question

How to change values of read-only custom attributes programmatically?


Sudaraazhi Arivalagan (441728) | asked Dec 08 '14, 6:50 a.m.

Hi,

Kindly someone help me for this need.

I would require to programmatically update custom attribute values. I am getting failed in both the operations below.

  1. If i enable "Read-only" for that attribute, getting server exception "CRRTC0299E: The work item with the ID 137 cannot be saved because an attempt was made to change the attributes '[ID-StatusChange History]' which are not modifiable."
  2. If i uncheck the field "Permissions" for all the roles, Team Advisor error saying "Permission Denied"

Please advise.

Thanks

Sudar

Accepted answer


permanent link
Susan Hanson (1.6k2201194) | answered Dec 08 '14, 7:03 a.m.
My understanding is that if you make the *attribute* read-only, then the attribute is read-only regardless of what method is attempting to change it (UI vs API).

You can make the attribute show as Read-only in the editor  but leave the attribute itself read-write, which would allow the APIs to change it (assuming the userid which is running the API has permissions to change the attribute) but the anyone using the UI (eclipse/web) would see it as a R/O attribute and not be able to change anything.

Susan
Sudaraazhi Arivalagan selected this answer as the correct answer

Comments
Sudaraazhi Arivalagan commented Dec 08 '14, 7:12 a.m.

Thank you so much Susan !!

I use API method to change the values, UI should be read-only[non-editable]

How do i make the attribute itself read-write?

Thanks !


Sudaraazhi Arivalagan commented Dec 08 '14, 7:17 a.m.

As you say,

If i enable the attribute "Read-only" in the editor, and userid has permission to edit that field, I get the server exception error.

If i disable the field "Read-only" in the editor, and userid has permission to edit that field, this allows user to edit that field in UI(eclipse)

:(


1
Susan Hanson commented Dec 08 '14, 7:37 a.m.

If you edit the custom attribute (for example, I use the Eclipse UI), There is a "read-only" checkbox near the bottom above the Dependency block.  You would have that NOT checked, so that means the attribute itself is read-write.

Then in the editor, you set  the Presentation itself to Read Only (about 1/2 way down in the Edit Presentation dialog is Read-Only, which in the one that I have that works like this, it is set to "True".  This makes it R/O for anybody that uses the Editor Presentation, so all of the UIs.

In Permissions, make sure that the role that the userid running the APis has contains the proper edit permissions on the attribute.

During the execution of the APIs, the API only knows about the R/O characteristics of the attribute itself, not of the editor.  So it allows editing.

If you are still getting the exception, perhaps double-check the R/O characteristic of the attribute itself (edit the custom attribute on the work item at the bottom of the work item type editing window).


Sudaraazhi Arivalagan commented Dec 08 '14, 8:05 a.m.

Great !!

Works fine.

Thank you so much Susan...

Your answer


Register or 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.