Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Need to make Date field readonly

Sanjivani Wayal
Contributor
March 4, 2024

Hi,

there is a requirement where 1 date field needs to be editable only for few users in a group or maybe not editable removing it from edit screen is not helping as it is getting removed from view screen as well cant use workflow as its not based on transition

tried to use ScriptRunner for the same with below script but its not working can anyone help with correction of the script-

 

const user = await makeRequest("/rest/api/2/myself");

const { accountId } = user.body;

const getRoles = await makeRequest(`/rest/api/2/user/groups?accountId=${accountId}`);

const roleNames = getRoles.body.map(({ name }) => name);

 const role = "name of security group";

if (!roleNames.includes(role)) {

  getFieldById("customfield_10534").setReadOnly(true);

}

2 answers

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2024

Hi Sanjivani,

You can achieve this requirement using the Behaviours feature of ScriptRunner for Jira Cloud.

We have an example script here that shows how to make fields read-only to users in specific groups, and you will be able to update this to achieve your requirement.

Regards,

Kristian

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2024

Hi Sanjivani,

You can have separate Edit and View screens. Leave the field on the View screen and remove it from the Edit screen. 

Then create a self-looping transition on the status with Conditions that allow only certain people to execute the transition. 

Then add a transition screen with the field on the screen to the transition. 

Sanjivani Wayal
Contributor
March 8, 2024

Hi @John Funk 

removing it from edit screen is not helping as it is getting removed from view screen as well , also cant use workflow as its not based on transition if the field is in same status anyone can change it

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2024

You need to create separate screens for Edit and View. Then leave it on the View screen and remove it from the Edit screen. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Jira Events