Forums

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

Add Screen programatically in a plugin

anonykhoa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 25, 2018

Hi,

Is there some example of how i can add Field screens programatically in a plugin?

I want to add new screen with a lot of custom field for workflow transition in my plugin and when I change status, it will be displayed. I can not find any example of how to do this.

I am new to JIRA dev so would welcome some examples thank you in advance

1 answer

0 votes
Kubilay Karpat [Snapbytes]
Contributor
July 26, 2018

Hi Jayce,

 

Welcome to the community! I think you can have a look at FieldScreenManager and FieldScreenFactory. Not actually tried but something like this might work:

 

FieldScreenManager fieldScreenManager;
FieldManager fieldManager;

FieldScreen newScreen = fieldScreenFactory.createScreen();
newScreen.setName("My new screen");

FieldScreenTab newTab = newScreen.addTab("New tab");
Field myField = fieldManager.getField("customfield_10000");
newTab.addFieldScreenLayoutItem(myField.getId());
newScreen.store();

 

anonykhoa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 26, 2018

Thanks Kubilay!

I added new Screen in my plugin. I'm trying to add it into a transition of workflow, but it doesn't work. Can you help me to check this code below?

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("TP-1");
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
JiraWorkflow workflow = workflowManager.getWorkflow(issue);
Collection<ActionDescriptor> allActions = workflow.getAllActions();
Map<String, String> metaAttributes=new HashMap<String, String>();

metaAttributes.put("jira.fieldscreen.id", newScreen.getId().toString());
for(ActionDescriptor aActions : allActions){
if(aActions.getName().equals("Plan")){
aActions.setView("Waiting to test");
aActions.setMetaAttributes(metaAttributes);
}
}

Suggest an answer

Log in or Sign up to answer