Add custom columns
To display workflow data in inbox, we need to define and populate variables in the workflow. The value of the variable needs to be set before a task is assigned to a user. To give you a head start we have provided sample workflow that is ready to be deployed on your AEM server.
This workflow has two variables defined(isMarried and income) and its values are set using the set variable component. These variables are made available as columns to be added to AEM inbox
Create service
For every column that we need to display in our inbox we would need to write a service. The following service allows us to add a column to display the value of the isMarried variable
import com.adobe.cq.inbox.ui.column.Column;
import com.adobe.cq.inbox.ui.column.provider.ColumnProvider;
import com.adobe.cq.inbox.ui.InboxItem;
import org.osgi.service.component.annotations.Component;
import java.util.Map;
/**
* This provider does not require any sightly template to be defined.
* It is used to display the value of 'ismarried' workflow variable as a column in inbox
*/
@Component(service = ColumnProvider.class, immediate = true)
public class MaritalStatusProvider implements ColumnProvider {@Override
public Column getColumn() {
return new Column("married", "Married", Boolean.class.getName());
}
// Return True or False if 'ismarried' is set. Else returns null
private Boolean isMarried(InboxItem inboxItem) {
Boolean ismarried = null;
Map metaDataMap = inboxItem.getWorkflowMetadata();
if (metaDataMap != null) {
if (metaDataMap.containsKey("isMarried")) {
ismarried = (Boolean) metaDataMap.get("isMarried");
}
}
return ismarried;
}
@Override
public Object getValue(InboxItem inboxItem) {
return isMarried(inboxItem);
}
}
Test on your server
- Login to AEM web console
- Deploy and start inbox customization bundle
- Open your inbox
- Open Admin Control by clicking List View icon next to Create button
- Add Married column to Inbox and save your changes
- Go to FormsAndDocuments UI
- Import the sample form by selecting File Upload from Create menu
- Preview the form
- Select the marital status and submit the form
view inbox
Submitting the form will trigger the workflow and a task is assigned to “admin” user. You should see a value under the Married column as shown in this screen shot