<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger</link><pubDate>Mon, 24 Jun 2019 18:45:08 GMT</pubDate><guid isPermaLink="false">567c1b49-171b-41a9-9d2a-5b63b5df8fb0</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger#comments</comments><description>Current Revision posted to Developer Training by Former Member on 06/24/2019 18:45:08&lt;br /&gt;
&lt;p&gt;When an automation should executed periodically and not in direct relation to a specific action, it can be triggered based on a schedule. When executed on a schedule, the automation will execute on the job server.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Triggering_Automations_using_a_Schedule" name="Triggering_Automations_using_a_Schedule"&gt;&lt;/a&gt;Triggering Automations using a Schedule&lt;/h2&gt;
&lt;p&gt;To enable an automation to be&amp;nbsp;executed periodically on a schedule,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;On the automation&amp;#39;s &lt;strong&gt;Overview&lt;/strong&gt;, locate &lt;strong&gt;Triggers&lt;/strong&gt;, and check &lt;strong&gt;Scheduled&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the schedule type from the drop-down and provide details required by the schedule type.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/scheduled.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Using_Scheduled_Triggers_in_Automation_Implementations" name="Using_Scheduled_Triggers_in_Automation_Implementations"&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;Using Scheduled Triggers in Automation Implementations&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Each enabled instance of a scheduled automation will appear in the jobs listing (&lt;strong&gt;Administration &amp;gt; Monitoring &amp;gt; Jobs&lt;/strong&gt;) with its next execution time. When the scheduled execution time occurs, the automation is executed. When the automation completes, its next scheduled time will be calculated and the job listing will be updated to reflect the automation&amp;#39;s next execution time. When executed manually, details about the schedule are provided through the &lt;code&gt;context_v2_automationTrigger&lt;/code&gt; API:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Entity&lt;/strong&gt;. For scheduled triggers, the Entity is always &amp;quot;Job&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Event&lt;/strong&gt;. For scheduled triggers, the Event is always &amp;quot;Executed&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Arguments&lt;/strong&gt;. For scheduled triggers, Arguments provides two properties:&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;IsCancellationRequested&lt;/strong&gt;. Automations run on a schedule are allowed to run for an extended period of time on the job server. If the job server requests that the current task end, the IsCancellationRequested argument will change to true. For long running automations, this property should be checked periodically and the process should be cancelled if possible when it is set to true.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Schedule&lt;/strong&gt;. The current configured schedule for the automation. This is for reference to enable the automation to know roughly how frequently it is executed.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;&lt;a id="Example_of_a_Scheduled_Trigger" name="Example_of_a_Scheduled_Trigger"&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;Example of a Scheduled Trigger&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;Below is a simple example of utilizing an automation with a scheduled trigger. For this scenario, we would like to deactivate users who have not logged in to the site for a certain amount of time.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_the_Automation" name="Creating_the_Automation"&gt;&lt;/a&gt;Creating the Automation&lt;/h2&gt;
&lt;p&gt;After&amp;nbsp;following the dialog in &lt;strong&gt;Administration &amp;gt; Automation &amp;gt; Automation Studio&lt;/strong&gt; to create a new&amp;nbsp;automation, we set the schedule to run once daily and to use the service account in order to manage user details.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x0/__key/communityserver-wikis-components-files/00-00-00-12-83/Automation_5F00_DeactivateOldUsers.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Any&amp;nbsp;instance of this automation will need to specify a time frame to use when determining which users to deactivate, so in the Configuration section of our automation, we add options for length of time and unit of measure (days or years).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;propertyGroup id=&amp;quot;options&amp;quot; labelText=&amp;quot;Options&amp;quot;&amp;gt;
    &amp;lt;property id=&amp;quot;age&amp;quot; labelText=&amp;quot;Age&amp;quot; descriptionText=&amp;quot;Number of units to measure&amp;quot; dataType=&amp;quot;Int&amp;quot; defaultValue=&amp;quot;1&amp;quot; /&amp;gt;
    &amp;lt;property id=&amp;quot;ageUnit&amp;quot; labelText=&amp;quot;Unit of Measure&amp;quot; descriptionText=&amp;quot;Calculate in days or years&amp;quot; dataType=&amp;quot;String&amp;quot; defaultValue=&amp;quot;y&amp;quot;&amp;gt;
        &amp;lt;propertyValue value=&amp;quot;y&amp;quot; labelText=&amp;quot;Years&amp;quot; /&amp;gt;
        &amp;lt;propertyValue value=&amp;quot;d&amp;quot; labelText=&amp;quot;Days&amp;quot; /&amp;gt;
    &amp;lt;/property&amp;gt;
&amp;lt;/propertyGroup&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In the Implementation section of our automation, we can then retrieve these values, ensure we have them, and ensure they are valid before continuing execution. In this process we also generate the cutoff date we will use for later comparison.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;var unit = core_v2_widget.GetStringValue(&amp;#39;ageUnit&amp;#39;, &amp;#39;&amp;#39;);
if(unit === &amp;#39;&amp;#39;) {
    return;
}

var age = core_v2_widget.GetIntValue(&amp;#39;age&amp;#39;, 0);
if(age === 0) {
    return;
}

var currentDate = core_v2_utility.CurrentDate;
var cutoff = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), 0, 0, 0);

if(unit === &amp;#39;y&amp;#39;)
{
    cutoff.setFullYear(cutoff.getFullYear() - age);
}
else if (unit === &amp;#39;d&amp;#39;)
{
    cutoff.setDate(cutoff.getDate() - age);
}
else return;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;All that&amp;#39;s left is to iterate through the site&amp;#39;s users and check their LastVisitedDate. This can be done through use of&amp;nbsp;the&amp;nbsp;user [[Scripting|scripting/widget API]]. We check each user&amp;#39;s LastVisitedDate and update the user to Disapproved when necessary.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;var pageIndex = 0;
var done = false;
while(!done) {
    var users = core_v2_user.List({
       SortBy: &amp;#39;LastVisitedDate&amp;#39;,
       SortOrder: &amp;#39;Ascending&amp;#39;,
       PageSize: 100,
       PageIndex: pageIndex
    });
    
    for(var i = 0; i &amp;lt; users.Count; i++) {  
        if(!users[i].IsSystemAccount &amp;amp;&amp;amp; users[i].JoinDate !== null &amp;amp;&amp;amp; users[i].JoinDate &amp;lt;= cutoff) {
            core_v2_user.Update({ AccountStatus: &amp;#39;Disapproved&amp;#39;, Id: users[i].Id });
        }
    }
    
    if(users.TotalCount &amp;lt;= 100 * (pageIndex + 1)) {
        done = true;
    }
    
    pageIndex++;
}&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Configuring_an_Automation_Instance" name="Configuring_an_Automation_Instance"&gt;&lt;/a&gt;Configuring an Automation Instance&lt;/h2&gt;
&lt;p&gt;In &lt;strong&gt;Administration &amp;gt; Automation &amp;gt; Automations&lt;/strong&gt;, we create a new Automation instance and specify the type. This then allows us to specify the configuration details we created the options for in our automation.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x0/__key/communityserver-wikis-components-files/00-00-00-12-83/ConfiguredAutomation_5F00_DeactivateOldUsers.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Once the instance is saved,&amp;nbsp;the automation&amp;nbsp;will run according to the specified schedule until all instances are disabled or deleted.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Source_code" name="Source_code"&gt;&lt;/a&gt;Source code&lt;/h2&gt;
&lt;p&gt;Full source is attached below.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/DeactivateOldUsers_2D00_Automation.xml"&gt;community.telligent.com/.../DeactivateOldUsers_2D00_Automation.xml&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger/revision/6</link><pubDate>Mon, 24 Jun 2019 18:14:57 GMT</pubDate><guid isPermaLink="false">567c1b49-171b-41a9-9d2a-5b63b5df8fb0</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger#comments</comments><description>Revision 6 posted to Developer Training by Former Member on 06/24/2019 18:14:57&lt;br /&gt;
&lt;p&gt;When an automation should executed periodically and not in direct relation to a specific action, it can be triggered based on a schedule. When executed on a schedule, the automation will execute on the job server.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Triggering_Automations_using_a_Schedule" name="Triggering_Automations_using_a_Schedule"&gt;&lt;/a&gt;Triggering Automations using a Schedule&lt;/h2&gt;
&lt;p&gt;To enable an automation to be&amp;nbsp;executed periodically on a schedule,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;On the automation&amp;#39;s &lt;strong&gt;Overview&lt;/strong&gt;, locate &lt;strong&gt;Triggers&lt;/strong&gt;, and check &lt;strong&gt;Scheduled&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the schedule type from the drop-down and provide details required by the schedule type.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/scheduled.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Using_Scheduled_Triggers_in_Automation_Implementations" name="Using_Scheduled_Triggers_in_Automation_Implementations"&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;Using Scheduled Triggers in Automation Implementations&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Each enabled instance of a scheduled automation will appear in the jobs listing (&lt;strong&gt;Administration &amp;gt; Monitoring &amp;gt; Jobs&lt;/strong&gt;) with its next execution time. When the scheduled execution time occurs, the automation is executed. When the automation completes, its next scheduled time will be calculated and the job listing will be updated to reflect the automation&amp;#39;s next execution time. When executed manually, details about the schedule are provided through the &lt;code&gt;context_v2_automationTrigger&lt;/code&gt; API:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Entity&lt;/strong&gt;. For scheduled triggers, the Entity is always &amp;quot;Job&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Event&lt;/strong&gt;. For scheduled triggers, the Event is always &amp;quot;Executed&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Arguments&lt;/strong&gt;. For scheduled triggers, Arguments provides two properties:&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;IsCancellationRequested&lt;/strong&gt;. Automations run on a schedule are allowed to run for an extended period of time on the job server. If the job server requests that the current task end, the IsCancellationRequested argument will change to true. For long running automations, this property should be checked periodically and the process should be cancelled if possible when it is set to true.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Schedule&lt;/strong&gt;. The current configured schedule for the automation. This is for reference to enable the automation to know roughly how frequently it is executed.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;&lt;a id="Example_of_a_Scheduled_Trigger" name="Example_of_a_Scheduled_Trigger"&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;Example of a Scheduled Trigger&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;Below is a simple example of utilizing an automation with a scheduled trigger. For this scenario, we would like to deactivate users who have not logged in to the site for a certain amount of time.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_the_Automation" name="Creating_the_Automation"&gt;&lt;/a&gt;Creating the Automation&lt;/h2&gt;
&lt;p&gt;After&amp;nbsp;following the dialog in &lt;strong&gt;Administration &amp;gt; Automation &amp;gt; Automation Studio&lt;/strong&gt; to create a new&amp;nbsp;automation, we set the schedule to run once daily and to use the service account in order to manage user details.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x0/__key/communityserver-wikis-components-files/00-00-00-12-83/Automation_5F00_DeactivateOldUsers.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Any&amp;nbsp;instance of this automation will need to specify a time frame to use when determining which users to deactivate, so in the Configuration section of our automation, we add options for length of time and unit of measure (days or years).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;propertyGroup id=&amp;quot;options&amp;quot; labelText=&amp;quot;Options&amp;quot;&amp;gt;
    &amp;lt;property id=&amp;quot;age&amp;quot; labelText=&amp;quot;Age&amp;quot; descriptionText=&amp;quot;Number of units to measure&amp;quot; dataType=&amp;quot;Int&amp;quot; defaultValue=&amp;quot;1&amp;quot; /&amp;gt;
    &amp;lt;property id=&amp;quot;ageUnit&amp;quot; labelText=&amp;quot;Unit of Measure&amp;quot; descriptionText=&amp;quot;Calculate in days or years&amp;quot; dataType=&amp;quot;String&amp;quot; defaultValue=&amp;quot;y&amp;quot;&amp;gt;
        &amp;lt;propertyValue value=&amp;quot;y&amp;quot; labelText=&amp;quot;Years&amp;quot; /&amp;gt;
        &amp;lt;propertyValue value=&amp;quot;d&amp;quot; labelText=&amp;quot;Days&amp;quot; /&amp;gt;
    &amp;lt;/property&amp;gt;
&amp;lt;/propertyGroup&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In the Implementation section of our automation, we can then retrieve these values, ensure we have them, and ensure they are valid before continuing execution. In this process we also generate the cutoff date we will use for later comparison.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;var unit = core_v2_widget.GetStringValue(&amp;#39;ageUnit&amp;#39;, &amp;#39;&amp;#39;);
if(unit === &amp;#39;&amp;#39;) {
    return;
}

var age = core_v2_widget.GetIntValue(&amp;#39;age&amp;#39;, 0);
if(age === 0) {
    return;
}

var currentDate = core_v2_utility.CurrentDate;
var cutoff = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), 0, 0, 0);

if(unit === &amp;#39;y&amp;#39;)
{
    cutoff.setFullYear(cutoff.getFullYear() - age);
}
else if (unit === &amp;#39;d&amp;#39;)
{
    cutoff.setDate(cutoff.getDate() - age);
}
else return;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;All that&amp;#39;s left is to iterate through the site&amp;#39;s users and check their LastVisitedDate. This can be done through use of&amp;nbsp;the&amp;nbsp;user [[Scripting|scripting/widget API]]. We check each user&amp;#39;s LastVisitedDate and update the user to Disapproved when necessary.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;var pageIndex = 0;
var done = false;
while(!done) {
    var users = core_v2_user.List({
       SortBy: &amp;#39;LastVisitedDate&amp;#39;,
       SortOrder: &amp;#39;Ascending&amp;#39;,
       PageSize: 100,
       PageIndex: pageIndex
    });
    
    for(var i = 0; i &amp;lt; users.Count; i++) {  
        if(!users[i].IsSystemAccount &amp;amp;&amp;amp; users[i].JoinDate !== null &amp;amp;&amp;amp; users[i].JoinDate &amp;lt;= cutoff) {
            core_v2_user.Update({ AccountStatus: &amp;#39;Disapproved&amp;#39;, Id: users[i].Id });
        }
    }
    
    if(users.TotalCount &amp;lt;= 100 * (pageIndex + 1)) {
        done = true;
    }
    
    pageIndex++;
}&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Configuring_an_Automation_Instance" name="Configuring_an_Automation_Instance"&gt;&lt;/a&gt;Configuring an Automation Instance&lt;/h2&gt;
&lt;p&gt;In &lt;strong&gt;Administration &amp;gt; Automation &amp;gt; Automations&lt;/strong&gt;, we create a new Automation instance and specify the type. This then allows us to specify the configuration details we created the options for in our automation.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x0/__key/communityserver-wikis-components-files/00-00-00-12-83/ConfiguredAutomation_5F00_DeactivateOldUsers.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Once the instance is saved,&amp;nbsp;the automation&amp;nbsp;will run according to the specified schedule until all instances are disabled or deleted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger/revision/5</link><pubDate>Mon, 24 Jun 2019 18:14:06 GMT</pubDate><guid isPermaLink="false">567c1b49-171b-41a9-9d2a-5b63b5df8fb0</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger#comments</comments><description>Revision 5 posted to Developer Training by Former Member on 06/24/2019 18:14:06&lt;br /&gt;
&lt;p&gt;When an automation should executed periodically and not in direct relation to a specific action, it can be triggered based on a schedule. When executed on a schedule, the automation will execute on the job server.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Triggering_Automations_using_a_Schedule" name="Triggering_Automations_using_a_Schedule"&gt;&lt;/a&gt;Triggering Automations using a Schedule&lt;/h2&gt;
&lt;p&gt;To enable an automation to be&amp;nbsp;executed periodically on a schedule,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;On the automation&amp;#39;s &lt;strong&gt;Overview&lt;/strong&gt;, locate &lt;strong&gt;Triggers&lt;/strong&gt;, and check &lt;strong&gt;Scheduled&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the schedule type from the drop-down and provide details required by the schedule type.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/scheduled.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Using_Scheduled_Triggers_in_Automation_Implementations" name="Using_Scheduled_Triggers_in_Automation_Implementations"&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;Using Scheduled Triggers in Automation Implementations&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Each enabled instance of a scheduled automation will appear in the jobs listing (&lt;strong&gt;Administration &amp;gt; Monitoring &amp;gt; Jobs&lt;/strong&gt;) with its next execution time. When the scheduled execution time occurs, the automation is executed. When the automation completes, its next scheduled time will be calculated and the job listing will be updated to reflect the automation&amp;#39;s next execution time. When executed manually, details about the schedule are provided through the &lt;code&gt;context_v2_automationTrigger&lt;/code&gt; API:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Entity&lt;/strong&gt;. For scheduled triggers, the Entity is always &amp;quot;Job&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Event&lt;/strong&gt;. For scheduled triggers, the Event is always &amp;quot;Executed&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Arguments&lt;/strong&gt;. For scheduled triggers, Arguments provides two properties:&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;IsCancellationRequested&lt;/strong&gt;. Automations run on a schedule are allowed to run for an extended period of time on the job server. If the job server requests that the current task end, the IsCancellationRequested argument will change to true. For long running automations, this property should be checked periodically and the process should be cancelled if possible when it is set to true.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Schedule&lt;/strong&gt;. The current configured schedule for the automation. This is for reference to enable the automation to know roughly how frequently it is executed.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;&lt;a id="Example_of_a_Scheduled_Trigger" name="Example_of_a_Scheduled_Trigger"&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;Example of a Scheduled Trigger&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;Below is a simple example of utilizing an automation with a scheduled trigger. For this scenario, we would like to deactivate users who have not logged in to the site for a certain amount of time.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_the_Automation" name="Creating_the_Automation"&gt;&lt;/a&gt;Creating the Automation&lt;/h2&gt;
&lt;p&gt;After&amp;nbsp;following the dialog in &lt;strong&gt;Administration &amp;gt; Automation &amp;gt; Automation Studio&lt;/strong&gt; to create a new&amp;nbsp;automation, we set the schedule to run once daily and to use the service account in order to manage user details.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x0/__key/communityserver-wikis-components-files/00-00-00-12-83/Automation_5F00_DeactivateOldUsers.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Any&amp;nbsp;instance of this automation will need to specify a time frame to use when determining which users to deactivate, so in the Configuration section of our automation, we add options for length of time and unit of measure (days or years).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;propertyGroup id=&amp;quot;options&amp;quot; labelText=&amp;quot;Options&amp;quot;&amp;gt;
    &amp;lt;property id=&amp;quot;age&amp;quot; labelText=&amp;quot;Age&amp;quot; descriptionText=&amp;quot;Number of units to measure&amp;quot; dataType=&amp;quot;Int&amp;quot; defaultValue=&amp;quot;1&amp;quot; /&amp;gt;
    &amp;lt;property id=&amp;quot;ageUnit&amp;quot; labelText=&amp;quot;Unit of Measure&amp;quot; descriptionText=&amp;quot;Calculate in days or years&amp;quot; dataType=&amp;quot;String&amp;quot; defaultValue=&amp;quot;y&amp;quot;&amp;gt;
        &amp;lt;propertyValue value=&amp;quot;y&amp;quot; labelText=&amp;quot;Years&amp;quot; /&amp;gt;
        &amp;lt;propertyValue value=&amp;quot;d&amp;quot; labelText=&amp;quot;Days&amp;quot; /&amp;gt;
    &amp;lt;/property&amp;gt;
&amp;lt;/propertyGroup&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In the Implementation section of our automation, we can then retrieve these values, ensure we have them, and ensure they are valid before continuing execution. In this process we also generate the cutoff date we will use for later comparison.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;var unit = core_v2_widget.GetStringValue(&amp;#39;ageUnit&amp;#39;, &amp;#39;&amp;#39;);
if(unit === &amp;#39;&amp;#39;) {
    return;
}

var age = core_v2_widget.GetIntValue(&amp;#39;age&amp;#39;, 0);
if(age === 0) {
    return;
}

var currentDate = core_v2_utility.CurrentDate;
var cutoff = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), 0, 0, 0);

if(unit === &amp;#39;y&amp;#39;)
{
    cutoff.setFullYear(cutoff.getFullYear() - age);
}
else if (unit === &amp;#39;d&amp;#39;)
{
    cutoff.setDate(cutoff.getDate() - age);
}
else return;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;All that&amp;#39;s left is to iterate through the site&amp;#39;s users and check their LastVisitedDate. This can be done through use of&amp;nbsp;the&amp;nbsp;user [[scripting/widget API|Scripting]]. We check each user&amp;#39;s LastVisitedDate and update the user to Disapproved when necessary.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;var pageIndex = 0;
var done = false;
while(!done) {
    var users = core_v2_user.List({
       SortBy: &amp;#39;LastVisitedDate&amp;#39;,
       SortOrder: &amp;#39;Ascending&amp;#39;,
       PageSize: 100,
       PageIndex: pageIndex
    });
    
    for(var i = 0; i &amp;lt; users.Count; i++) {  
        if(!users[i].IsSystemAccount &amp;amp;&amp;amp; users[i].JoinDate !== null &amp;amp;&amp;amp; users[i].JoinDate &amp;lt;= cutoff) {
            core_v2_user.Update({ AccountStatus: &amp;#39;Disapproved&amp;#39;, Id: users[i].Id });
        }
    }
    
    if(users.TotalCount &amp;lt;= 100 * (pageIndex + 1)) {
        done = true;
    }
    
    pageIndex++;
}&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Configuring_an_Automation_Instance" name="Configuring_an_Automation_Instance"&gt;&lt;/a&gt;Configuring an Automation Instance&lt;/h2&gt;
&lt;p&gt;In &lt;strong&gt;Administration &amp;gt; Automation &amp;gt; Automations&lt;/strong&gt;, we create a new Automation instance and specify the type. This then allows us to specify the configuration details we created the options for in our automation.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x0/__key/communityserver-wikis-components-files/00-00-00-12-83/ConfiguredAutomation_5F00_DeactivateOldUsers.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Once the instance is saved,&amp;nbsp;the automation&amp;nbsp;will run according to the specified schedule until all instances are disabled or deleted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger/revision/4</link><pubDate>Wed, 19 Jun 2019 21:17:57 GMT</pubDate><guid isPermaLink="false">567c1b49-171b-41a9-9d2a-5b63b5df8fb0</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger#comments</comments><description>Revision 4 posted to Developer Training by Ben Tiedt on 06/19/2019 21:17:57&lt;br /&gt;
&lt;p&gt;When an automation should executed periodically and not in direct relation to a specific action, it can be triggered based on a schedule. When executed on a schedule, the automation will execute on the job server.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Triggering_Automations_using_a_Schedule" name="Triggering_Automations_using_a_Schedule"&gt;&lt;/a&gt;Triggering Automations using a Schedule&lt;/h2&gt;
&lt;p&gt;To enable an automation to be&amp;nbsp;executed periodically on a schedule,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;On the automation&amp;#39;s &lt;strong&gt;Overview&lt;/strong&gt;, locate &lt;strong&gt;Triggers&lt;/strong&gt;, and check &lt;strong&gt;Scheduled&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the schedule type from the drop-down and provide details required by the schedule type.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/scheduled.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a id="Using_Scheduled_Triggers_in_Automation_Implementations" name="Using_Scheduled_Triggers_in_Automation_Implementations"&gt;&lt;/a&gt;&lt;span style="font-weight:400;"&gt;Using Scheduled Triggers in Automation Implementations&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Each enabled instance of a scheduled automation will appear in the jobs listing (&lt;strong&gt;Administration &amp;gt; Monitoring &amp;gt; Jobs&lt;/strong&gt;) with its next execution time. When the scheduled execution time occurs, the automation is executed. When the automation completes, its next scheduled time will be calculated and the job listing will be updated to reflect the automation&amp;#39;s next execution time. When executed manually, details about the schedule are provided through the &lt;code&gt;context_v2_automationTrigger&lt;/code&gt; API:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Entity&lt;/strong&gt;. For scheduled triggers, the Entity is always &amp;quot;Job&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Event&lt;/strong&gt;. For scheduled triggers, the Event is always &amp;quot;Executed&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Arguments&lt;/strong&gt;. For scheduled triggers, Arguments provides two properties:&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;IsCancellationRequested&lt;/strong&gt;. Automations run on a schedule are allowed to run for an extended period of time on the job server. If the job server requests that the current task end, the IsCancellationRequested argument will change to true. For long running automations, this property should be checked periodically and the process should be cancelled if possible when it is set to true.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;&lt;strong&gt;Schedule&lt;/strong&gt;. The current configured schedule for the automation. This is for reference to enable the automation to know roughly how frequently it is executed.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger/revision/3</link><pubDate>Tue, 18 Jun 2019 18:35:27 GMT</pubDate><guid isPermaLink="false">567c1b49-171b-41a9-9d2a-5b63b5df8fb0</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger#comments</comments><description>Revision 3 posted to Developer Training by Former Member on 06/18/2019 18:35:27&lt;br /&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;If you&amp;rsquo;re familiar with Verint Community&amp;rsquo;s Job scheduling structure, you&amp;rsquo;ll recognize the interface for scheduling automations. Select a frequency through a few configuration options, and this automation will run exactly like a job would, executing its implemented scripting at regular intervals. More documentation is available in-site via links below the schedule configuration.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/scheduled.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger/revision/2</link><pubDate>Tue, 18 Jun 2019 18:35:01 GMT</pubDate><guid isPermaLink="false">567c1b49-171b-41a9-9d2a-5b63b5df8fb0</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger#comments</comments><description>Revision 2 posted to Developer Training by Former Member on 06/18/2019 18:35:01&lt;br /&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;If you&amp;rsquo;re familiar with Verint Community&amp;rsquo;s Job scheduling structure, you&amp;rsquo;ll recognize the interface for scheduling automations. Select a frequency through a few configuration options, and this automation will run exactly like a job would, executing its implemented scripting at regular intervals.More documentation is available in-site via links below the schedule configuration.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;img alt=" " border="0" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/scheduled.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Scheduled Trigger</title><link>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger/revision/1</link><pubDate>Fri, 14 Jun 2019 20:53:01 GMT</pubDate><guid isPermaLink="false">567c1b49-171b-41a9-9d2a-5b63b5df8fb0</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65566/scheduled-trigger#comments</comments><description>Revision 1 posted to Developer Training by Ben Tiedt on 06/14/2019 20:53:01&lt;br /&gt;
&lt;p&gt;TBD&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>