It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need to make a custom field readonly after saving the form

Hi All,

 I have a form and there is a custom field called request type and this is a select list. Select list containes some values as [ test, project, defect]. if i save form as selecting defect from list this custom field supposed to be readOnly and shouldnt be updated.

I tried some code and managed to make field readonly,  But in edit mode when i change request type form test to defect without saving the form this filed become immediately readonly. I need to make it work  after saving the form.

if (getAction()?.id == 1)// Do not make field readonly on  Create mode
{
return
}

def CustomField_ = getFieldByName("Request Type")

def selectedOption = CustomField_.getValue() as String

def isOtherSelected = (selectedOption == "Defect" )

CustomField_.setReadOnly(isOtherSelected);

 

2 answers

0 votes
Fadoua Community Leader Dec 08, 2019

@Sema YILDIRIM if no other fields need to be updated later then you have 2 options:

  • Either update the project permission if it is not shared, and grant the edit issue only to certain people.
  • Or add workflow properties (Be careful with this option as it may create problems for you if you try to do a Bulk Edit)

Best,

Fadoua

Hi @Sema YILDIRIM ,

an easy way to prevent users from editing certain fields is to

  • add this field to a transition screen only so it's only editable on executing a transition, e.g. the Create one
  • don't add/remove this field from the edit screen of your issue type so it can't be edited via the common Edit operation

Cheers
Thorsten

Hi @Thorsten Letschert _Decadis AG_ ,

where is it "Edit operation"? I can prevent it from being read only in the creat section. But how do I intervene in the edit section?

 

if (getAction()?.id == 1) // Do not run script on Create action
{
return
}

Hi @Sema YILDIRIM ,

sorry for having been too quick with my initial response. With regard to your use case, I've been successful in the past by adapting the solution provided by Joshua here: https://community.atlassian.com/t5/Jira-Service-Desk-questions/Can-t-hide-Comment-field-on-Edit-screen-using-methods-provided/qaq-p/676381

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you