Need to make Date field readonly

Sanjivani Wayal 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 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
Site Admin
TAGS
AUG Leaders

Atlassian Community Events