How to change values of read-only custom attributes programmatically?
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.
- 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."
- If i uncheck the field "Permissions" for all the roles, Team Advisor error saying "Permission Denied"
Please advise.
Thanks
Sudar
Accepted answer
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
Comments
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 !
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)
:(
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).
1 vote
Great !!
Works fine.
Thank you so much Susan...