<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Cron to delete articles by structure field</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112492925" />
  <subtitle>Cron to delete articles by structure field</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112492925</id>
  <updated>2026-04-04T21:48:26Z</updated>
  <dc:date>2026-04-04T21:48:26Z</dc:date>
  <entry>
    <title>RE: Cron to delete articles by structure field</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112495768" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112495768</id>
    <updated>2019-02-27T15:17:18Z</updated>
    <published>2019-02-27T15:17:18Z</published>
    <summary type="html">I stand corrected. :-)&lt;br /&gt;&lt;br /&gt;For this task, David&amp;#39;s way is better.&lt;br /&gt;&lt;br /&gt;​​​​​​​Fernando</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2019-02-27T15:17:18Z</dc:date>
  </entry>
  <entry>
    <title>RE: Cron to delete articles by structure field</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112494854" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112494854</id>
    <updated>2019-02-27T15:06:46Z</updated>
    <published>2019-02-27T15:06:46Z</published>
    <summary type="html">Instead of putting it in the structure, just use the expiration date on the article itself.&lt;br /&gt;&lt;br /&gt;Liferay will automagically expire it at that time and you won&amp;#39;t need to do any custom coding.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-02-27T15:06:46Z</dc:date>
  </entry>
  <entry>
    <title>RE: Cron to delete articles by structure field</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112494229" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112494229</id>
    <updated>2019-02-27T14:55:06Z</updated>
    <published>2019-02-27T14:55:06Z</published>
    <summary type="html">&lt;blockquote&gt;Iñigo Boyano&lt;br /&gt;&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;In the doRecive method is where i have to code the logic to find the articles to delete, right? It&amp;#39;s posible in that module to access liferay services like DDMStructureLocalService or others in order to get the articles by structure.&lt;/li&gt;&lt;li&gt;I don&amp;#39;t understant the function of the methods &amp;#39;activate&amp;#39;, &amp;#39;deactivate&amp;#39;.&lt;/li&gt;&lt;li&gt;Is there any other better way to achieve this funcionality that is not to develop a cron module?&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Hi Íñigo,&lt;br /&gt;&lt;br /&gt;Yes, the doReceive is the method that runs your task and you can access Liferay services from there.&lt;br /&gt;&lt;br /&gt;The activate/deactivate methods are run when your module enters/exits the OSGi container and should be the ones who register/deregister your task and your task runner.&lt;br /&gt;&lt;br /&gt;I think this is a good way of doing this. ;-)&lt;br /&gt;&lt;br /&gt;HTH&lt;br /&gt;&lt;br /&gt;Fernando</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2019-02-27T14:55:06Z</dc:date>
  </entry>
  <entry>
    <title>Cron to delete articles by structure field</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112492924" />
    <author>
      <name>Iñigo Boyano</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112492924</id>
    <updated>2019-02-27T13:46:31Z</updated>
    <published>2019-02-27T13:46:31Z</published>
    <summary type="html">Hi, &lt;br /&gt;&lt;br /&gt;I have to develop a module in Liferay DXP to delete journalArticles based on a structure field of those contents, the structure have a field called &amp;#39;cancelationDate&amp;#39; to determine when the Article is useless. From that date, the content won&amp;#39;t show in the portal but will persist in BBDD. After a &amp;#39;x&amp;#39; days after that date, the article would be deleted from BBDD.&lt;br /&gt;&lt;br /&gt;I think about developing a cron job module to delete from BBDD those articles every sunday for example. I&amp;#39;ve read the following post about cron jobs looking for some info:&lt;br /&gt;https://community.liferay.com/blogs/-/blogs/liferay-7-ce-liferay-dxp-scheduled-tasks, but i don&amp;#39;t know how to start.&lt;br /&gt;&lt;br /&gt;&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;In the doRecive method is where i have to code the logic to find the articles to delete, right? It&amp;#39;s posible in that module to access liferay services like DDMStructureLocalService or others in order to get the articles by structure.&lt;/li&gt;&lt;li&gt;I don&amp;#39;t understant the function of the methods &amp;#39;activate&amp;#39;, &amp;#39;deactivate&amp;#39;.&lt;/li&gt;&lt;li&gt;Is there any other better way to achieve this funcionality that is not to develop a cron module?&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Kind regards, &lt;br /&gt;&lt;br /&gt;Íñigo</summary>
    <dc:creator>Iñigo Boyano</dc:creator>
    <dc:date>2019-02-27T13:46:31Z</dc:date>
  </entry>
</feed>
