so the functionality I'm trying to create is the user gives me a date eg 06/28/2020 and on 07/28/2020 I'll:
send them a notification
change the date I was storing from 06/28/2020 to 7/28/2020
start tracking for 08/28/2020 to repeat 1 & 2.
And I want to do this automatically. I can do the notification but I'm stuck on how to keep track of the date automatically every day to compare between today's date and the end date which is the 28th of next month and make the changes. Does firebase or nodejs have some feature/package to do this behind the scene without any external events after the user has input the end date?
Right now I can get the dates from firestore and compare it with today's date but ONLY when I have an event like when I go to my profile page. I can also update the date for next month using dateJS. But if I don't go to my page it won't trigger the function. I want to make it automatic and store it somewhere where it doesn't require a user's interaction to trigger it but happens automatically.
Note: The date can be different based on user input so it's not a fixed date. And I'm using NodeJS and firebase for my project.
Any help will be appreciated. Thanks!
You could make a cloud function that runs every 24 hours using pubsub. You can then get the current date using something like
const currentDate = new Date();
You can then check if that day is today, by checking if the timestamp in firestore is between now and 24 hours in the future. I would advice using the moment dependency for that. You could do something like:
const currentDate = new Date();
const tomorrow = moment(currentDate).add(24, 'hours');
if(yourDate > currentDate && yourDate < tomorrow){
// send notification
// update to next month
const nextMonth = moment(currentDate).add(1, 'month');
db.collection(path).doc(docId).update({
yourDate: nextMonth,
});
}
Note that this is pseudo code, I haven't fully tested it but I have used a similar technique in the past. This should do the trick for you I think
Related
I am a newbie in fullstack development. I am doing my first project using postgresql, nodejs and express(ejs template). In my task list project i have a duedate option, where i enter a duedate(date picker) for a task and it get saved in the postgres database. I have an edit option aswell with a datepicker. how can i retreive the date in the 'dd/mm/yyyy' format from the database and display it inthe date picker in the edit page?.is it possible. Please help.
Thanks
What gets stored in the DB for date will probably look different then what you see on the front-end, simply because date / time is usually stored as UTC etc ( this will depend on how you have the table configured)
Next, you can use javascript built in date function like toLocaleDateString('en-US') to get a mm/dd/yyyy format from the stored date in the DB
What this means is that on the front-end you would pull the date from the DB as normal, then for the date-picker you would just pass the date over like
let myDate = new date([date from db); // this create a new date object off the date from the DB
//Now we make is a readable date
// myDate = myDate.toLocaleDateString('en-US'); // will give mm/dd/yyyy
I am trying to calculate the last working day for a process. Typically, this will be yesterday. However, if the process runs on a Monday it should bring back the date of Friday.
My calculation is:
Today()-MakeTimeSpan(1, 0, 0, 0)
Current code stage
The Best Practice in this area is to use VBO called "Calendars", that is a Internal one, built in the BluePrism.
Object: Calendar
Action: Add working days
Calendar Name: "Working Week / No Holidays"
Date: Today()
Days -1
An advantage of that solution is that you can customize the calendar to add all Holidays that are Bank Holidays for your company.
In the past, I've been able to accomplish this by using a dedicated Utilities object with an action that's just a single code stage. The action has a single Output connected to a single output of the Code stage.
out = DateTime.Now.AddDays(-1)
While out.DayOfWeek = DayOfWeek.Saturday Or out.DayOfWeek = DayOfWeek.Sunday
out = out.AddDays(-1)
End While
This also opens the ability for you to add complex logic to account for holidays in your locale(s) without cluttering up your action page.
I have google sheet that i want to use every day (like a main template), where I just need to add a few values in a specific cells,
i want to be able automatically or not to set those cell values everyday (let's say at midnight) back to my default values (let's say 0 or 1).
Any clue, any help,
Thanks.
You can use script triggers to run your script every nth hour.
Triggers: https://developers.google.com/apps-script/guides/triggers/installable
Check "Managing triggers manually" section.
You will have to create a script in google spreadsheet to change the values to a default value and setup up triggers to run that script every nth hour or so.
So all I need to do was create a script for a sheet
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var range = sheet.getRange("B2");
var values = range.getValues();
if(values > 0) {
range.setValue(0);
}
}
And after that Click on Resources, Current project's triggers.
Add new trigger and set it like this:
I think that's it, it is tested and work.
If something is missing please edit my answer,deleting trigger or something like that.
I am developing marketing campaign , I want to insert the day name in campaign. I Try to add date using custom field but it is not possible . Please suggest any solution
I didn't find any direct way to get current day in AgileCRM campaigns. However I can suggest using JSONIO node with URL http://www.convert-unix-time.com/api?date=now&timezone=vienna to get current date and time w.r.t timezone. You can use {{localDate}} as merge field wherever you need after JSONIO node.
In SharePoint 2007 document library I want to send automatic email notification to user two days before expiry date.
After expiry date document will remain in the library.
Any suggestions would really be appreciated.
You just need to create workflow in SharePoint designer. During creation of an item the workflow starts and waits until execution date. If expiry date can be changed you need another action which cancels old workflow (with old date) and starts new one (with need date).
Here you can find instruction how it can be done in SPD
Create a SharePoint Designer (SPD) workflow
Select your task list
Set it to run on Create
Click Next
In the Actions section add these three actions:
- Add time to date
- Pause until date
- Send email
My example looks like this after the properties are set:
Add -7 days to Tasks:Due Date (Output to Variable: ReminderDate)
then Pause until Variable: Reminder Date
then Email this message (you can hard code the address or use the assigned to... )
Notes for this very simple example:
- If someone edits the task and sets a new due date, this workflow will still send the reminder based on the old date.
- It does not check to see if the Due Date is at least two days in the future.
Ref: http://social.msdn.microsoft.com/Forums/en-US/acb12dd2-d6a5-4b7e-b233-037558bfa2e5/start-workflow-x-days-before-expiry-date?forum=sharepointcustomizationlegacy