I am trying to set value to a field or trying to hide a field for my project using groovy script or by enabling readonly button in Behaviour. But not working.
Please help me to fix this.
Hello @Pramod.Kumar.Ojha ,
You may not require the component accessor line here. Can you check with below script based on your requirement - If type is Race Subtask then readonly to duration and dclink field as hidden.
def issueTypeField = getFieldById("issuetype")
def currentIssueType = issueTypeField.getValue()
// Fields to manipulate
def durationField = getFieldByName("Estimated Duration (w)")
def dcLinkField = getFieldByName("DataCenter Link")
if (currentIssueType == "Rack Sub-task") {
// Make duration field read-only
durationField.setReadOnly(true)
// Hide DataCenter Link field
dcLinkField.setHidden(true)
// Optionally set a default value
durationField.setFormValue("5")
} else {
// Reset to writable and visible if not "Rack Sub-task"
durationField.setReadOnly(false)
dcLinkField.setHidden(false)
}
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.
could you please try like this:
getFieldByName('DataCentre Link').setReadOnly(true)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its not working.
I already have working code which is working in Staging environment. But same code is not working in production.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any sort of error or something else you can share?
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.
I am able to set the field values of a different project on jira. But the issue is for specific project("IaaS DCPM"). Though we are not getting any error in behaviour but the value is not set on the field.
Do we require any specific permission to set the field value on DCPM project.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pramod_Kumar_Ojha,
Do you need to exclude The "DataCenter Link" from your screen?
You can do it by many way
- Create new screen for your sub-task and remove this field from your screen
- Create a Field Configuration for your sub-task then hidden the field by Field Configuration
- Set Custom Field context to exclude your issue type.
- Set Hidden for this field only in the ScriptRunner Behaviour
Hope this helps!
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.