I have a plugin that creates a screen and adds some fields to it. I dont have a problem with adding custom fields, those are displayed correctly, but I havent found a way to add a system field onto the screen, e.g. Summary. I would like to use the new screen for creating a special new issue type, but I need the required system fields on it for that.
I have tried to retrieve the Summary FieldScreenLayoutItem from the Default Field Screen and add it to the tab - while debugging, it seems to have added the field into the collection, there is no error displayed, but when I open the newly created screen in JIRA, the Summary field is missing.
FieldScreen createScreen = new FieldScreenImpl(fieldScreenManager);
createScreen.setName(PROJECT_CREATE_SCREEN_NAME);
createScreen.store();
createScreen.addTab("Details");
FieldScreenTab tab = createScreen.getTab(0);
tab.addFieldScreenLayoutItem(someCustomField.getId()); //this works well
//This retrieves the summaryItem correctly
FieldScreen defaultFieldScreen = fieldScreenManager.getFieldScreen(FieldScreen.DEFAULT_SCREEN_ID);
FieldScreenTab defaultTab = defaultFieldScreen.getTab(0);
FieldScreenLayoutItem summaryItem = null;
for(FieldScreenLayoutItem item : defaultTab.getFieldScreenLayoutItems()){
if(item.getFieldId().equals("summary")){
summaryItem = item;
break;
}
}
//this seems to work in the debugger - the item is added in the collection, gets new id etc.
tab.addFieldScreenLayoutItem(summaryItem.getId().toString());
I know I could avoid all this by creating a whole new project template, but I would like to avoid that if possible.