Skip to content

Instantly share code, notes, and snippets.

@000benniu
000benniu / emailSendScript
Created July 23, 2025 07:13
Liferay Email Send test
// Liferay Groovy Script to send a test email.
// This script demonstrates how to use Liferay's MailServiceUtil to send an email.
// Before running, ensure your Liferay instance's SMTP settings are correctly configured
// in Control Panel -> System Settings -> Mail.
import com.liferay.mail.kernel.model.MailMessage;
import com.liferay.mail.kernel.service.MailServiceUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import javax.mail.internet.InternetAddress;
@000benniu
000benniu / PortletEmbedderHtml
Last active June 27, 2025 01:34
PortletEmbedder
<div class="PortletEmbedder">
[@liferay_portlet["runtime"] portletName="${configuration.portlet}"/]
</div>
@000benniu
000benniu / sample.html
Last active October 30, 2023 01:32
Object/Headless API fragment
<div id="loadmore" class="btn btn-sm btn-primary">データ取得</div>
<div id="loadmore2" class="btn btn-sm btn-primary">データ取得&画面更新</div>
<?xml version="1.0"?>
<workflow-definition
xmlns="urn:liferay.com:liferay-workflow_7.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:liferay.com:liferay-workflow_7.4.0 http://www.liferay.com/dtd/liferay-workflow-definition_7_4_0.xsd"
>
<name>e2426a9f-ae0c-8cff-5733-53ee5b5f123e</name>
<description>重要なお知らせに対し、広報室長がレビューする</description>
<version>26</version>
import com.liferay.portal.kernel.exception.PortalException
import com.liferay.portal.kernel.model.User
import com.liferay.portal.kernel.service.UserLocalServiceUtil
try {
// You can replace 'userId' with the actual user's ID
def user = UserLocalServiceUtil.getUser(44386)
def companyId = user.getCompanyId()
println "Company ID for User ${user.getScreenName()}: $companyId"
} catch (PortalException e) {
@000benniu
000benniu / ConditionSample.txt
Last active December 9, 2022 02:39
Kaleo Condition Check script Sample
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
import com.liferay.portal.kernel.service.ServiceContext;
try {
System.out.println("=====================Start Script================================");
System.out.println("=====================workflowContext================================");
workflowContext.each{ k, v -> System.out.println "${k}:${v}" }
<#include "${templatesPath}/NAVIGATION-MACRO-FTL" />
<#if !entries?has_content>
<#if themeDisplay.isSignedIn()>
<div class="alert alert-info">
<@liferay.language key="there-are-no-menu-items-to-display" />
</div>
</#if>
<#else>
<#assign
[#assign assetEntry = "" /]
[#assign trackingId = "" /]
[#assign infoListDisplayObject = (request.getAttribute("INFO_LIST_DISPLAY_OBJECT"))! /]
[#assign liferaySharedLayoutAssetEntry = (request.getAttribute("LIFERAY_SHARED_LAYOUT_ASSET_ENTRY"))! /]
[#if infoListDisplayObject?has_content]
[#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService") /]
[#assign modelClassName = infoListDisplayObject.modelClassName! /]
[#assign resourcePrimKey = infoListDisplayObject.resourcePrimKey! /]
<#--
Dump all the values for web contents.
Use as asset publisher's template. (tested on DXP 7.1)
-->
<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
<#if entries?has_content>
<#list entries as curEntry>
<#assign journalArticle = journalArticleLocalService.getLatestArticle(curEntry.getClassPK()) />
<@liferay_journal["journal-article"]
@000benniu
000benniu / related_asset_fetch_sample.ftl
Created April 6, 2022 06:17 — forked from yasuflatland-lf/related_asset_fetch_sample.ftl
Fetch Related Assets in Web Content Template