Google Script Run ClockTrigger Multiple Scripts - email

The situation I have is this:
a google form signup where people can sign up for notifications
a series of scripts that I would like to run nightly that looks through the form responses and emails people appropriately, Emailer()
an unsubscribe script that ideally runs frequently (every hour or so would be enough) as well as right before the notifications email is
sent. This looks through the inbox for emails and removes the
appropriate entries from the form responses, Unsubscriber()
I am having trouble coming up with a way to coordinate the way these two scripts will run. What I would like to happen is to have Unsubscriber() run every hour or so throughout the day. At midnight or some late night hour, I would like to run Emailer() once and have the Unsubscriber() function not be running at this time. Once Emailer() completes, I would like the Unsubscriber() function to resume running at its regular interval. I feel like this should be possible using a ClockTrigger, but I can't envision how to make it happen.
I am also wondering, if the Unsubscriber() function is scheduled to run every hour with a ClockTrigger, but takes longer than an hour on a certain instance, will the ClockTrigger start a second instance of the script?

Here is the documentation on how to create manually a time trigger, you can set the function to run every hour.
This trigger could be related to a main function in which you could evaluate the current time, if its in the range of midnight (e.g. 12am < current time > 1am) call the function Emailer(), for every other time of the day call Unsuscriber().
Hope this helps.

Related

UiPath Orchestrator Triggers - Cron Expression For specific day of month or next working day if not a working day

I've currently got this Cron expression that I'm using to trigger a process in UiPath Orchestrator:
0 0 15 21W * ? *
Runs on the closest working day to the 21st of each month at 3pm.
However I need it to run on the next working day at 3pm if the 21st is a non working day.
Tried searching for an answer and nothing quite fit the brief.
I used this website to build my expression (which is a great tool) but it only had an option for 'nearest day' and not next working day given a specific day of month: https://www.freeformatter.com/cron-expression-generator-quartz.html
As you don't need the nearest day, you can't use the functionality of Orchestrator cronjob. I would recommend creating a wrapper process as follows:
Create a new process, let's call it StartJobByCheckingDate
Now create a trigger that starts StartJobByCheckingDate each day at 3pm
So that process is now your manager of your desired process
Now we need to check if it is the 21th day
Here you have different ways to solve it
You could create a DataTable or even a file in the StartJobByCheckingDate process, that contains all the different days where your desired process should be fired (but this is very manual, you might not want to update this every year, so this might not be the smartest but the easiest solution)
The other idea is to check if the current day is the 21th day. If so check if it is Saturday/Sunday (non-working day).
If true: you could now create a empty dummy file somewhere that tracks that the 21th was a non-working day, and the next day you check that file existing, if it exists you check the current day to be a working day, and if so you delete the file again and start your desired process
If false: just start your desired process directly
I think 2. idea would be that best. Sure you have 365 jobs runs/year. But when you keep that helper process smart this will just be seconds.
Another idea instead of using the dummy file, would be to use Entities. Smarter but need some more time to get familiar with.
We have (had) the exact same issue. Since UiPath doesn't offer a feasible solution out of the box, we will work around the restriction using the following strategy: We trigger the actual job daily, considering a custom-built, static NonWorkingDay-list that will just suppress the execution of the robot every day we don't want it to run.
These steps are needed:
Get a list with of all known bank holidays, saturdays and sundays until 2053 or so...
Build a the static exclusion-list using a script that does something like this (pseudocode. I will update the answer once we have actually implemented the solution):
1. get all valid execution dates
loop through every 28th of the month until end of 2053
if the date is in the bankHolidayList then
loop until the next bankDay is found
add it to the list of valid ExecutionDates
else
add the date to the validExecutionDate-list
2. build exclusion-list
loop through every day until end of 2053
if the date is not in the validExecutionDate-list
add it to the exclusionDate-list
Format the csv accordingly and upload it to the orchestrator tenant as a NonWorkingDay-List
Update your trigger to run daily at your desired time, using the uploaded NonWorkDay-Calendar
While the accepted answer will surely work as well, we prefered to go with this approach because having a separate robot that does nothing but executing a UiPath trigger just doesn't seem right to me. With this approach we have no additional code that we potentially need to maintain.
In my oppinion not having a solution for this concern out of the box is a lack of feature that UiPath will (hopefully) fix until end of 2053 ;-)
Cheers
You can configure your trigger to launch oftener, then manage dates at init of your process, but you must set up a list of "holydays" or check in some way.
Also you can use the calendar option of orchestrator (+info)

Day Exception in Events in AnyLogic

I am currently doing a simulation model in AnyLogic of a Distribution Center where from Monday to Saturday I use an event to trigger the loading of a truck. I wish to program this loading every day at the same time, but how can I do it so it happens everyday EXCEPT Sundays. I currently have it as triggered: timeout and mode: cyclic, using calendar dates...
sure, the easy way is to just add a manual exception to the schedule as below:
And the more advanced way is to use a Dynamic Event that executes your daily action.
In the model start code, call create_MyDynamicEvent(7, DAY) to make it trigger after the first 7 days of the sim.
Then in the Dynamic Event action code, add whatever should happen every day. And also add a line that re-creates the same Dynamic event in 1 day, like
create_MyDynamicEvent(1, DAY)
This would then trigger every day, even Sunday. To avoid that, you can add an if-clause in the dynamic event action code to only execute your code if it is not Sunday.

Google Sheet IMPORTHTML VERY Slow?

I have a spreadsheet that acquires some table data using the IMPORTHTML function, and for the first two days I was using it (refreshing twice daily) things were going fine. As of this morning, it is absolutely crawling. Went from taking ~15 seconds to load 30 rows to taking ~10 minutes. Can somebody lend aid on this?
Example formula:
=IMPORTHTML(
"http://www.muthead.com/16/players/prices/1508-markus-wheaton/playstation-4","table",2
)
As mentioned, the first couple of days it was able to refresh and process a list of 30 without any pauses. Now I get the 'Executing script' message for about ten minutes before it begins to do anything, and I haven't touched the source code since origin. I'm not sure what contributes to the performance of the IMPORTHTML statement...
I've run into similar loading issues when using IMPORTHTML, IMPORTDATA, etc. The best solution I've found is to write a trigger that will edit your formula so it is forced to refresh every hour or so.
Open up the script editor and put this in. Change 'A1' with the cell your IMPORTHTML function is in, and change foo to the URL you're trying to import.
function refreshData() {
var range = SpreadsheetApp.getActiveSpreadsheet().getRange('A1');
range.clear();
range.setFormula('=IMPORTHTML(foo)');
}
Then go to Edit > Current Project Trigger > Add Trigger, and set a refresh interval.
Hope this helps.

Dynamics CRM workflow failing with infinite loop detection - but why?

I want to run a plug-in every 30 minutes, to poll an external system for changes. I am in CRM Online, so I don't have ready access to a scheduling engine.
To run the plug-in, I have a 'trigger' entity with a timezone independent date-
Updating the field also triggers a workflow, which in pseudocode has this logic:
If (Trigger_WaitUntil >= [Process-Execution Time])
{
Timeout until Trigger:WaitUntil
{
Set Trigger_WaitUntil to [Process-Execution Time] + 30 minutes
Stop Workflow with status of: Succeeded
}
}
If Trigger_WaitUntil < [Process-Execution Time])
{
Send email //Tell an admin that the recurring task has self-terminated
Stop Workflow with status of: Canceled
}
So, the behaviour I expect is that every 30 minutes, the 'WaitUntil' field gets updated (and the Plug-in and workflow get triggered again); unless the WaitUntil date is before the Execution time, in which case stop the workflow.
However, 4 hours or so later (probably 8 executions, although I haven't verified that yet) I get an infinite loop warning "This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again. For information about workflow".
My question is why? Do workflows have a correlation id like plug-ins, which is being carried through to the child workflow? If so, is there anyway I can prevent this, whilst maintaining the current basic mechanism of using a single trigger record to manage the schedule (I've seen other solutions in which workflows create new records, but then you've got to go round tidying up the old trigger records as well)
Yes, this behavior is well-known. The only way to implement recurring workflows without issues with infinite loops in Dynamics CRM and using only OOB features is usage of Bulk Deletion functionality. This article describes how to implement it - http://www.crmsoftwareblog.com/2012/08/using-the-bulk-deletion-process-to-schedule-recurring-workflows/
UPD: If you want to run your code every 30 mins then you will have to create 48 bulkdelete jobs with correspond startdatetime like 12:00, 12: 30, 1:00 ...
The current supported method for CRM is to use the Azure Scheduler.
Excerpt:
create a Web API application to communicate with CRM and our external
provider running on a shared (free) Azure web site and also utilize
the Azure Scheduler to manage the recurrence pattern.
The free version of the Azure Scheduler limits us to execution no more
than once an hour and a maximum of 5 jobs. If you have a lot going on
$20 a month will get you executions every minute and up to 50 jobs -
which sounds like a pretty good deal.
so if you wanted every 30 minutes, you could create two jobs, one on the half hour, and one on the hour.
The Bulk Deletion is an interesting work around and something we've used before. It creates extra work and maintenance though so I try to avoid it if possible.
I would generally recommend building a windows application and using the windows scheduling feature (I know you said you don't have a scheduler available but this is often forgotten). This approach works really well and is very easy to troubleshoot. Writing to logs and sending error email alerts is pretty easy to make it robust. The server doesn't need to be accessible externally, it only needs to reach CRM. If you had CRM on-prem, you could just use the same server.
Azure Scheduler is a great suggestion. This keeps you in the cloud which is nice.
SSIS is another option if you already have KingswaySoft or Cozy Roc in place.
You could build a workflow that creates another record and cleans up after itself; however, this is really using the wrong tool for the job. Also, it's very easy for it to fail and then not initiate the next record.
There is a solution called "Scheduled Workflow Runner". You create a FetchXML query to create a record set to run against, and point it at an on-demand workflow that you want it to run on each record.
http://alexanderdevelopment.net/post/2013/05/18/scheduling-recurring-dynamics-crm-workflows-with-fetchxml/

Need to Make a Parse Cloud Code Job to Reset all Objects at a Certain Time of Day

I currently have an app powered by parse that monitors the wait times for a certain amusement park. On parse, each ride has its own class file and in each class there is an object with a string entitled "waitTime" which has a string that has the most recent wait time submitted. I would like to use cloud code to reset all of the waitTime sections of each object to "0" at 1:00 AM each morning. I have no experience with Cloud Code or anything like it. How would I go about doing something like this? Thank you in advance for your help!
Have a job that runs every 5 minutes, comparing the current server time to any scheduled times (e.g. 1am, including timezone issues), and if it matches run that task (in your case resetting the "waitTime").
It is common to have this single master job trigger multiple different tasks (functions in your cloud code) using different rules such as time or a manual job queue, that's why I suggest this pattern.