[5.6-RC3] Custom operation java code - some properties don't get set

Hello all,

I have a custom operation java code that creates an object (a CaseLink) and sets some data on it.

Set properties works for all properties but one (at least, what I'm seeing) which stays null. There no custom properties involved. The property I cannot set is case_link / caseItemId.

I've checked with the debugger: all the properties are set on the memory object, including the one that I find null in the DB afterword.

There is no error message in the logs.

How can I debug this? Do you see any reason for the set on a particular property not to work?


Here is the code:

@Operation( id = CreateCaseLinkOperation_withLastCaseItem.ID, 
        category = CaseConstants.CASE_MANAGEMENT_OPERATION_CATEGORY, 
        label = "Case Link creation", 
        description = "Create a CaseLink to be used latter in the chain," +
                      " takes on input a CaseItem, retrieves        ")
public class CreateCaseLinkOperation_withLastCaseItem {

public final static String ID = "MyPrefix.Case.Management.CreateCaseLink";

OperationContext context;

private CaseManagementDocumentTypeService correspDocumentTypeService;

public DocumentModelList createCaseLink(DocumentModelList docs) {
    CoreSession session = context.getCoreSession();
    List<CaseLink> links = new ArrayList<CaseLink>();
    try {
        for (DocumentModel doc : docs) {

            DocumentModel linkDoc = session.createDocumentModel(getCaseManagementDocumentTypeService().getCaseLinkType());

            // retrieve current user name mailboxId
            String currentUserMailboxId = "";
                Principal prin = session.getPrincipal();                    
                try {
                    MailboxManagementService mbMngtService = Framework.getService(MailboxManagementService.class);
                    currentUserMailboxId = mbMngtService.getUserPersonalMailboxId(prin.getName());
                } catch (Exception e) {

            // set case ID
            linkDoc.setPropertyValue( CaseLinkConstants.CASE_DOCUMENT_ID_FIELD, doc.getId() ); 

            // set case item ID (if any): taking the last case item in the case
            Case kase = doc.getAdapter(Case.class);
            List<CaseItem> list_ci = kase.getCaseItems(session);
            if ( list_ci.size() > 0 ) {
                String caseItemId = list_ci.get(list_ci.size() - 1).getDocument().getId();
                linkDoc.setPropertyValue( "cslk:caseItemId", caseItemId );                  

            // set sender mailboxId
            linkDoc.setPropertyValue("cslk:sender", currentUserMailboxId );

            // retrieve Case's responsible
            String responsible;
                // @TEMP
                responsible = currentUserMailboxId;
            } // retrieve Case's responsible                
            Map<String, List<String>> recipients = new HashMap<String, List<String>>();
            recipients.put(CaseLinkType.FOR_ACTION.name(), Arrays.asList(new String[] { responsible }));

            CaseLink cl = linkDoc.getAdapter(CaseLink.class);
        context.put(CaseConstants.OPERATION_CASE_LINKS_KEY, links);
    } catch (ClientException e) {
        throw new RuntimeException(e);
    return docs;


0 votes

0 answers



Hard to say without seeing your java code to understand what you do through it. Can you copy into your question your java code ?