Greetings,
I am new here and this is my first question!
I have completely stripped the adaptivist example https://scriptrunner.adaptavist.com/5.4.47/jira/behaviours-overview.html down to
log.info "hide script start"
def hiddenCf = getFieldById("ActHidden")
log.info ("definitions complete")
hiddenCf.setHidden(true)
log.info "hide script ran"
And it returned:
2019-05-01 21:49:27,892 http-nio-8080-exec-18 INFO marie 1309x36109x1 1coeg1v 71.212.40.101,0:0:0:0:0:0:0:1 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.j.groovy.user.FieldBehaviours] hide script start
2019-05-01 21:49:27,892 http-nio-8080-exec-18 INFO marie 1309x36109x1 1coeg1v 71.212.40.101,0:0:0:0:0:0:0:1 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.j.groovy.user.FieldBehaviours] definitions complete
2019-05-01 21:49:27,892 http-nio-8080-exec-18 INFO marie 1309x36109x1 1coeg1v 71.212.40.101,0:0:0:0:0:0:0:1 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.j.groovy.user.FieldBehaviours] hide script ran
2019-05-01 21:49:27,893 http-nio-8080-exec-18 DEBUG marie 1309x36109x1 1coeg1v 71.212.40.101,0:0:0:0:0:0:0:1 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.jira.behaviours.BehaviourManagerImpl] Returning map: [ActHidden:[hidden:true]]
So, the script runs. It sets the value. Jira does not hide the field despite the fact it is set ActHidden:[hidden:true].
Am I missing something simple?
Thanks,
Lonn
Hello,
getFieldById, as the name suggests, work with the customfield id. So you need to write something like
def hiddenCf = getFieldById("customfield_19000")
You can get this id by hovering on "edit" button at the customfield, on customfields page. After that it should work.
Regards.
Thanks, Elifcan,
That's a great technique to use going forward for things like that. In this case, getFieldByName("ActHidden") is more appropriate since "ActHidden" is my custom field name.
Thanks,
Lonn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I recommend you use the ID, though, because if someday you decide to change the custom field's name, then your script and any other script that uses that custom field will stop working. That's why I always use custom field ID. Just wanted to remind you that :)
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
'def hiddenCf = getFieldById("ActHidden")'
you wrote 'ActHidden' as an example? If not you have to either use getFieldById("customfield_123456") or use getFieldByName("ActHidden")
also see: https://scriptrunner.adaptavist.com/5.4.47/jira/behaviours-api-quickref.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, that is my field name. You are right. I should use getFieldByName("ActHidden").
I'll report back if that makes any difference in the effectiveness of the script.
This has been sidelined for now but I think it would be cool to solve. It's a test snippet for a larger script intended to hide fields from specific users or groups.
Thanks for the link and the input,
Lonn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.