Adding system field onto a screen through Java API

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);

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()){
        summaryItem = item;

//this seems to work in the debugger - the item is added in the collection, gets new id etc.

I know I could avoid all this by creating a whole new project template, but I would like to avoid that if possible.

In case anyone ever stumbles upon this, I managed to solve it by retrieving the Summary field as an OrderableField.

OrderableField summaryField = fieldManager.getOrderableField("summary");
1 Like