Forums

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

I want to restrict to edit the "Summary" and "Description" fields for automatically created issues

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi Team,

 

I have an project in that some Tickets(issues) are created automatically through Phantom by the user  "Automation"(reporter) here the tickets that are created automatically by the user automation as reporter i want to restrict the permission to edit the "Summary" and "Description" fields for that auto created tickets. 

the only manually created ticket have permission to edit summary and description fields.

Can you please suggest me regards this.

 

Thanks,

Phani

2 answers

1 accepted

0 votes
Answer accepted
Gundlupet Sreenidhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

There are a couple ways you can achieve this:

Lets assume you are working on issue-type STORY

Option A: As Nic suggested, create a separate screen for the Edit.

1. Go to Administration --> Issues --> Screens

2. Create separate screens for how the STORY should look like during Create, Edit and View. 

i.e: You will be creating 3 different screens STORY - Create, STORY - EDIT, Story - VIEW

in each of these screens, only add the fields that should be available in those actions. 

In your example:

The STORY - create screen will have the summary and description

The STORY - Edit screen will not have the summary and description

The STORY - view screen will have the summary and description

3. Now go to screen schemes and create a story screen scheme

4. Here Map the actions: Create, Edit and View to the respective screens.

5. Go to Issue Type Screen Scheme and Map the STORY issue type to the screen scheme created above. 

You are all set. 

Now when creating the STORY, the summary and description can be entered. However, if you want to edit is will not be available to edit. 

Note: Care should be taken to put the correct details in the summary and description while creating the STORY. You will not have an option to edit them later. This impacts all issues of type STORY.

 

OPTION B: Using Behavior to control visibility and / or edit-ability

1. Go to Administration --> Add-ons --> Behaviors

2. Create a new behavior (Lets call it story behavior)

3. Create an initialiser.

if(!getFieldById("reporter").getValue().equals("automation")){
getFieldById(
"summary").setReadOnly(true)
getFieldById("description").setReadOnly(true)
}eles{
getFieldById("summary").setReadOnly(false)
getFieldById("description").setReadOnly(false)
}

4. (Optional) You can also add the Summary and description field to the behavior and make them read-only as shown in this example. You can even set conditions for when this should apply.

5. Map the behavior to your project and Issue type.

 

Now, every time the issue screen is opened for that project (either, create or edit mode) the behavior functionality will activate. 

Note: the behavior functionality is written to allow edit only for the automation user. All other users can only view the summary and description. You can modify this per your needs. 

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi, @Gundlupet Sreenidhi Thanks for your response on this issue I have tried the script as you suggested Plan B by using the Behavior so now I have already created manually some tickets for those tickets also I unable to edit the summary and Description and I'm unable to change even the Reporter.

manually created tickets the reporter is a different user I'm not using the "automation" user as a reporter for manually created tickets.

The thing is In the ticket reporter which is "Automation" only those tickets I don't want to edit anybody the "summary" and "Description" fields.

 

Thanks,

Phani

Gundlupet Sreenidhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

You can add an additional condition to the behavior to check if the user editing the issue is the same as the reporter. If so you can enable editing the summary and description. Else do not allow. 

 

import com.atlassian.jira.component.ComponentAccessor 
import com.atlassian.jira.user.ApplicationUser

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

if(!getFieldById("reporter").getValue().equals("automation")
||
getFieldById("reporter").getValue().equals(currentUser){
getFieldById(
"summary").setReadOnly(true)
getFieldById("description").setReadOnly(true)
}eles{
getFieldById("summary").setReadOnly(false)
getFieldById("description").setReadOnly(false)
}
Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi @Gundlupet Sreenidhi  Here I have tried like this Admin settings--->add-on--->behaviors---> created a behavior and given name as "SE" and then I clicked on "Field" In the Guided Workflow I have selected project workflow and I have selected "create initializer"  and I have added the script that you have given and saved it and I have mapped to particular project and particular issue type.

So, here how its working means I cannot edit the summary and Description and I'm Unable to change the reporter for some tickets my user I'd is a reporter even though for those tickets  I'm unable to change the reporter and Summary and description.

I can explain by giving an example:

Issue Type: SE

user I'd: automation

1) The Ticket Created if the reporter is " automation "  with issue type: "SE" those tickets should not be able to edit the Summary and Description Fields.

2) The tickets Created if the reporter is "xyz/any user" with Issue Type: "SE" those tickets should able to edit the Summary and Description Fields.

This is what i need to achieve I'm sorry by repeating the question If i did not follow your steps as you please suggest me 

 

Thanks,

Phani

Gundlupet Sreenidhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi @Kumar

Try this: 

Map the behavior only to the issue type and project

if the issue is create by "automation", then summary and description is non-editable

if the issue is not created by "automation", then summary and description is editable.

def reporter = underlyingIssue.reporter?.displayName

//Use the Reporter's full name in the condition
if(reporter.equalsIgnoreCase("automation")){
getFieldById("summary").setReadOnly(true)
getFieldById("description").setReadOnly(true)
}else{
getFieldById("summary").setReadOnly(false)
getFieldById("description").setReadOnly(false)
}
Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi @Gundlupet Sreenidhi  its working awesome thanks for your support you helped me a lot thank you so much 

 

Thanks,

Phani

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2018

Hi @Gundlupet Sreenidhi  So I have done another task simillary but in the new case I have two custom Fields called "Label (Multi Selected field)" and another is "Action( single select field ) .

Labels fields have options (A,B,C,D,E,F,H,G,H,I)

Action Field have options (X,Y)

I applied the same script with behavior its working same as above task like if i select Label field option(A,B,C) and (D,E,F)Action Field is populating.

but here i need a small change function has to work in my new task.

Here is the examples: 

 

1) while creating a ticket in Label field if i select (A,B,C) the Action filed has to populate and it has to select the Value with "X" automatically .

2)while i'm creating a ticket in the Lable field if i select (D,E,F) the Action field has to populate and it has to select the value with "Y" automatically.

if any ticket created with Label with rest of the option the action field does not required.

 

This is the task I have to achieve can you please help me to achieve this.

 

Thanks,

Phani

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2018

Hi @Gundlupet Sreenidhi  I have a small bug regards this task there is nothing wrong with script every thing is fine 

The thing is When a user wants to copy+paste content from the Summary or Description fields in the  project they click+drag to highlight the text. Then Jira opens the Edit screen. every time for every ticket for auto created ticket or manually created ticket when we try to copy the or highlight from those 3 fields its populating the edit screen.

Can you please help me here how to turn off that.

Thanks,

Phani

1 vote
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Remove the summary and description fields from the edit screen for that type of issue (you can't do it arbitrarily by a field, you need to use the issue type to determine the config)

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi @Nic Brough -Adaptavist- thanks your immediate response here in my project i'm using the only one issue type for every ticket.

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi @Nic Brough -Adaptavist-  can you please refer this link that i have posted another issue https://community.atlassian.com/t5/Jira-questions/The-Text-field-should-be-empty-when-I-select-another-options-in/qaq-p/921001#M295335   please respond on this also 

Thanks,

Phani

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Ok, well, you could use Behaviours in ScriptRunner to remove the fields from an edit screen, based on something like the "reporter", but that will not stop people from editing them in other ways.

I'd recommend separating the project into two issue types so you can remove the fields from the edit screen from the type where you don't want them.

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 22, 2018

Hi  @Nic Brough -Adaptavist-  Can You please help me with the behavior how to do please can you provide me any script adn how to follow that could be helpful for me 

 

Thanks,

Phani 

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2018

Hi @Gundlupet Sreenidhi  I have a small bug regards this task there is nothing wrong with script every thing is fine 

The thing is When a user wants to copy+paste content from the Summary or Description fields in the  project they click+drag to highlight the text. Then Jira opens the Edit screen. every time for every ticket for auto created ticket or manually created ticket when we try to copy the or highlight from those 3 fields its populating the edit screen.

Can you please help me her how to turn off that.

Thanks,

Phani

Gundlupet Sreenidhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2018

Hi Phani, 

If the issue is editable (not frozen) - then even though the summary and description are made non-editabled - when you click on the summary or description the issue opens the edit page (you will not be able to edit the sumnmary and description though). 

This is jira functionality. 

If you do not want the page to be editable, then you need to freeze the issue. Note - if you freeze the issue - then no changes (edits) can be made on the issue.

If this is what you wish - you can edit the workflow of the respective issuetype and on the status you wish - you can set a property : jira.issue.editable = false

for example: When an issue is closed, you do not want any changes to be made to the issue. So - edit the workflow of the issue and set a property on the CLOSE status as shown above.

 

If this is not what you want - you still need to edit the issue - then don't click (click & release) on the summary or description. You should still be able to hover over the summary or description and (click + drag, do not release the mouse) select the text without opening the edit screen.

Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2018

Hi @Gundlupet Sreenidhi  thanks for your response so here I dont want  to freeze the edit screen in particular status because we dont know the Users when they try to copy the text.

Here I have tried a new Plugin called https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=server&tab=pricing

this is working very good here i have tried an script with that i have achieved.

 

string [] groups = "X"; //Group Name
string [] allowedUser = usersInGroups(groups);

if(reporter == "automation" && arrayElementExists(allowedUser, currentUser()) == false) {
lfDisable("summary");
lfDisable("description");
lfDisable("reporter");
}
else if(reporter == "automation" && arrayElementExists(allowedUser, currentUser()) == true) {
lfDisable("summary");
lfDisable("description");
}


here I have Only i have a small problem I'm giving condition for the Groups to edit the reporter field but in above script I need give condition for Two groups when im trying to add other group to the script its not working .

 

Can you help me with above script to add the 2 groups have a permission to edit the reporter field.

 

Thanks,

Kumar 

Suggest an answer

Log in or Sign up to answer