legacy-knowledge-base
公開されました Jun. 30, 2025

groovyスクリプトでWebコンテンツの記事バージョンを削除する方法は?

written-by

Pooja Bhambani

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • ユーザーは、groovyスクリプトの助けを借りて、ウェブコンテンツの記事バージョンを削除する必要があります。

Environment

  • Liferay DXP 7.4

解決策

  • 以下は、Webコンテンツの記事版を削除するためのテンプレートgroovyスクリプトです。
    import com.liferay.portal.kernel.service.ServiceContext;
    import com.liferay.journal.service.JournalArticleLocalServiceUtil;
    import com.liferay.journal.model.JournalArticle;
    ServiceContext serviceContext = new ServiceContext();

    String articleId = "54703";
    long groupId= 20121;
    double version= 1.2d;
    String articleURL= "h1"; // Replace the values according to the environment

    JournalArticleLocalServiceUtil.deleteArticle(groupId, articleId, version, articleURL, serviceContext);
  • しかし、groovyスクリプトに関するさらなるサポートが必要な場合は、カスタム開発や実装を主に手がける当社の「グローバルサービスチーム」 にお気軽にお問い合わせください。

追加情報

  • この解決には、Liferay APIを使用してデータベースのエントリを変更する必要があるため、事前にデータベースのバックアップを作成し、ロールバックが必要な場合に備えて適切なバックアップを維持し続けることを確認してください。
  • 私たちは、上記の提案されたアプローチを低環境でテストし、それが快適だと感じたら、あなたの裁量で本番環境に移行することを強くお勧めします。
did-this-article-resolve-your-issue

legacy-knowledge-base