Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I want to hide clone option when External ID(text field) having some value from fragment script

jaya chandra reddy nellore May 11, 2022

Hi Folks,

 

I have a custom field External ID(text field) now i want to hide Clone option for issues having value in External ID field, I tried fragment script below but it is hiding clone option for all issues.

 

Script:

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours

def Source = getFieldByName('External ID').formValue
if(Source.toString().contains('IN') ) {
   return true
}
return false
----------
In if condition i tried with if(Source != null) also but its not working.
Thanks
Jaya

 

2 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
May 11, 2022

Hi @jaya chandra reddy nellore 

Could you please share a screenshot of your fragment configuration and a screenshot of your behaviour configuration?

Thank you and Kind regards,

Ram

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
May 11, 2022

Hi @jaya chandra reddy nellore

From the print screen that you have shared, it appears that you are using Behaviour code for the Fragment configuration. This approach will not work.

You should instead use:-

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager
def customField = customFieldManager.getCustomFieldObjectsByName('Sample Email').first()
def customFieldValue = issue.getCustomFieldValue(customField).toString().toUpperCase()

if (customFieldValue.contains("IN")) {
false
} else {
true
}

Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the Fragment configuration:-

fragment_config.png

Also, I am including a few test screens for your reference:-

1) First, the issue is created and the Sample Email field and set the value to in as shown below:-

test1.png

2) As expected, the Clone option is removed from the More options.

test2.png

3) Next, the Sample Email field is updated and changed to Tester which doesn't contain the IN characters as shown below:-

test3.png

4) As expected, the Clone option is not visible as shown below:-

test4.png

I hope this helps to answer your question. :)

Also, please respond in this thread as I wrong replied in @Vikrant Yadav's thread.

Thank you and Kind regards,

Ram

Like Vikrant Yadav likes this
jaya chandra reddy nellore May 11, 2022

@Ram Kumar Aravindakshan _Adaptavist_  Thanks for code its working.

0 votes
Vikrant Yadav
Community Champion
May 11, 2022
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
May 11, 2022

Hi @jaya chandra reddy nellore 

Could you please share a screenshot of your fragment configuration and a screenshot of your behaviour configuration?

Thank you and Kind regards,

Ram

jaya chandra reddy nellore May 11, 2022

@Ram Kumar Aravindakshan _Adaptavist_  Please check below screenshot;

Screenshot-fragment.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events