RE: Send Liferay User Notification for web content creation.

thumbnail
Jamie Sammons, modified 2 Years ago. New Member Posts: 9 Join Date: 1/13/21 Recent Posts

Hello Folks,
 

Can anyone suggest an approach for the below-mentioned requirement?

I have one structure in Liferay named news-letter now whenever any web content has been created or updated using that structure I want to send a notification to the specific users with one role named as staff in Liferay 7.4.

How should we achieve this in Liferay 7.4?

I really appreciate any help you can provide.

thumbnail
Russell Bohl, modified 2 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

Possibly a hack, not sure:

Add a workflow that has a condition--check the structure Id. If it's the structure you need a notification for, transition to a state node that has two jobs: send a notification and transition the item to the end state (where you should makr the item as approved). If it's not the structure you're interested in, just transition directly to the end state node (where you mark the item as approved).

 

Condition could look something like this:

import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.journal.service.JournalArticleLocalServiceUtil;
import com.liferay.journal.model.JournalArticle;
import com.liferay.portal.kernel.util.*;

long id = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));

JournalArticle ja = JournalArticleLocalServiceUtil.getJournalArticle(id);

if (ja.getDDMStructureId() == 34888) {
   returnValue = "fe262ad3-1b44-42d3-b790-f5c23679492a";
}

else {
   returnValue = "09ef78d1-daab-4d5b-81c0-bb92f92435c8";
}