When assignee changes I change the value of a custom field by using Adaptavist scriptrunner (I parse the company part from user email). But I need the field not to be edited by the user (only the script should update the field content).
Is it possible to make something like below:
1- make field read-only false
2- update field value
3- make field read-only true
I searched com.atlassian.jira.issue package but no such method like setReadOnly(boolean)
There is a simple way to do it - put the field on View screen of the issue and don't put the field on Edit screen of the issue. Users will see the field, but will not be able to change it manually.
Simply because fields, which are not present on Edit screen have the ability to click-and-edit disabled for them and they are not present on any screen, which can edit them.
Scriptrunner should be able to edit them anyway.
Your field must have data in it before it will appear on view, so you won't see it until the script has run.
You'll need to take another look at the script - I don't know how you are judging "run is successful", but to me that just means you know the script has run, not that has actually done what you want it to.
The script should not have any impact on the basic behaviour of JIRA.
I have just tested this on newest JIRA and it works just the way I told you and I was even able to modify custom field's text trough ScriptRunner without being able to edit it myself trough JIRA itself.
Could you please try to reproduce these steps:
1. Add new custom field to JIRA (make it e.g. test_custom_field and make it single line text field).
2. Put it on the View issue screen and Create issue screen, which differ from Edit issue screen for that particular issue and project
3. Create new issue and on creation issue screen, the field should be presented. Type any value in it.
4. After creation is completed, take a look on the issue, you newly custom created field should be here Note that you must have a value in the field to make it appear on View screen. The field is non editable and when you press "Edit" button, it is not presented on this screen.
For me, it works perfectly this way, even if I don't add it to Issue Creation screen.
If you are not sure about other things impacting behaviour of screens, you can try it on newly created test project.
Ok. I understand the second part of your answer.
The problem is with the first part. No matter how many times I change the assignee (the script runs that many times), I cannot see the custom field on view screen. When I add it to the edit screen also then it becomes visible (with data in it).
To test this behavior I followed the below steps:
1- Wrote the script under script listeners (custom)
2- Added the custom field (text) to the view screen only
3- Created an issue in the related project
4- Changed the assignee many times
5- "Nothing happened. The field is not visible on view screen"
6- Added the custom field to the edit screen also
7- I expected to see the field because I thought that the field value was filled before (by the previous runs of the script). But the field was not visible.
8- Changed the assignee
9- The field became visible on the view screen
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.Read more
Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs