In this section, you will learn how to get a panel content. The examples are in Java but they are applicable to Groovy
You will need to use the PanelContentService:
Getting a panel content
You will need to use PanelContentService.getPanel.
There are many definitions of the getPanel method, most of which are helper methods to this one :
- IssueRef represents a reference to an issue. Ex.: IssueRef.byId(12345) or IssueRef.byKey("ISSUE-123")
- PanelRef represents a reference to a panel. Ex.: PanelRef.byName("My panel")
- ReadOptions is a modifier that controls the behaviour of the method. This is explained below.
Panel read options
The ReadOptions parameter above controls the following behaviour of the getPanel method.
- Using readOptions.overrideSecurity() will allow to read panel without checking current logged-in user permissions.
- Using readOptions.withUser(anotherUser) will read the panel with the permission of the user in parameter
- Using readOptions.withCalculate() will enable calculate attributes and footers in the result.
This is an important option. When calculate is not enabled, calculate attributes will not be present in the result. The same applies to footers.
- Using readOptions.withEntities() will enable entities resolution. For example, if your panel contains a project component attribute, enabling entity resolution will give you access to the Component object. Otherwise, you would only have access to the component identifier.
This options applies to every entity attributes (see the list in Attribute Content Model)
Panel object structure
PanelItem / rows
A panel in composed of panel items (rows). Every panel item represents a rows. It has a content (PanelItemContent) which is every attribute content in the row.
Check Attribute Content Model for details about AttributeContent API
If your panel has the following structure :
The following code displays one text line per row.
If your panel contains calculate attributes, you need to explicitely use the ReadOptions parameter in the getPanel method:
If this parameter is not set, the calculate attributes will be missing in the Panel structure.
In the example above, we want to access the player information :
This example will not work unless you add the following :
If you do not explicitely ask for entities, only the userKey stored in the panel will be available.
When asking for entities, getPanel tries to resolve the associated entity and makes is available if found.
If you encountered problems when importing class ReadOptions into your groovy script, you should use another way to load this class :
In the case the referenced entity is not found, the content.getEntity() above will still return null
In Elements Checklist, a panel has a footer. The Panel structure has a getFooter() method that returns a PanelFooter instance.
As for calculate attributes, the footer is only available when using new ReadOptions().withCalculate()
Getting a defined attribute footer
In the example above (table with players and scores), if the score attribute has a sum footer defined in panel configuration, you can get it like this:
Calculating any footer
Even if your attribute does not have a footer defined, you can calculate any footer :