Forums

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

I want to restrict the Summary from being edited

Thomas Hardin
Contributor
May 1, 2020

 

I have a scenario where I need to restrict the Summary from being edited if a certain field is set to "Yes". I've tried to canvas the community for examples and have one that I thought would work, but I am not getting the results I expected.

if(!getFieldById("customfield_19114").getValue().equals("Yes")){
getFieldById("summary").setReadOnly(true)

}else{
getFieldById("summary").setReadOnly(false)

}

The custom field is a single-select Radio button and I just cannot get this to work.

If anyone can help, I'm eternally grateful. And, if you able to help, I have another piece to this puzzle, that I use help with. If the value of the custom field is "Yes", then I want the Summary to be read only, but not for users in a specific role. Now, I believe if I can get the initializer set, then I can use the field conditions to control the users who can edit. I may just need some confirmation on this.

 

Thanks for your help!

1 answer

1 accepted

1 vote
Answer accepted
Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 1, 2020

Hi @Thomas Hardin,

Below snippet will work for you to set summary readonly once field value is set

Map the Custom Field with behaviour and built server side script for the same with below code 

def ro = getFieldById(getFieldChanged()).getValue() == "Yes"
getFieldById("summary").setReadOnly(ro)

 Hope this helps you

 

BR,

Leo

Thomas Hardin
Contributor
May 4, 2020

Hi @Leo , I may be a bit lost and I may not have fully presented my scenario. But, I so not understand how the snippet would work in the initialize. In the case you provided, am I correct in that the field that changed (ro) is the same field we use to set read only? I thought Read Only was set to either True of False?

In my scenario, the field that should trigger the Summary to be Read Only is a "EOT Initiative", which is a radio button. If EOT Initiative = Yes, then we need to set the Summary to Read Only.

I truly appreciate your assistance on this and apologize for my lack of understanding.

Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 4, 2020

Hi @Thomas Hardin,

Yep, that is what above 2 lines are doing. setting summary to read only based on your custom field(EOT Initiative)

1. choose EOT Initiative for new behaviour

2. Select server side script

3. place those 2 lines

 

"getfieldchanged()" is the method to get field ID of associated/mapped field

so indirectly we are getting your custom field here, if you want you can replace it with yours like below

def ro = getFieldById(customfield_19114).getValue() == "Yes"
getFieldById("summary").setReadOnly(ro)

And in the first line if you notice I'm assigning value of getValue() == "Yes"

which means the variable "ro" will store either true or false

and in the 2nd line using ro value on summary field to enable/disable readonly option 

 

Hope this helps

 

BR,

Leo

Suggest an answer

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

Atlassian Community Events