How to delete the web content article version via groovy script?


  • Users need to delete the web content article version with the help of the groovy script.


  • Liferay DXP 7.4


  • Below is a template groovy script for deleting the web content article version.
    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);
  • However, in case of any further assistance with the groovy script, feel free to contact our "Global Service Team" which works primarily in custom development and implementations.

Additional Information

  • Since this resolution requires modification of database entries using Liferay API, ensure that a database backup is created beforehand and continue to maintain adequate backups in case a rollback is required.
  • We highly recommend testing the above-suggested approach in a lower environment and then move it to production as per your discretion if you feel comfortable with it.
Was this article helpful?
0 out of 0 found this helpful