It seems that the Restrict function is not working properly with Calendar items. Specifically, when a filter is passed to return calendar items within a specified time, then recurring meetings are returned do not occur between the times specified in the filter.
Problem can be reproduced as follows:
Calendar = outlook_mapi.GetDefaultFolder(OlDefaultFolders.olFolderCalendar)
all_messages = calendar.Items
all_messages.IncludeRecurrences = True
all_messages = all_messages.Restrict(f"[Start] >= '{date_str} 12:00AM' And [Start] <= '{date_str} 11:59PM'")
where date_str =f"{month}/{day}/{year}" and month/day/year is the particular date that we want to read the calendar
This then returns all recurring meetings in a user's calendar, irrespective of whether they occur on the specified time above or not.
Related
I'm attempting to use Cypress for an automated test that involves verifying that an appointment's information is being correctly entered into our system. In order to locate the appointment information, I'm locating the Date and Time on a table that the user is shown, and verifying the rest of the data from there. So my primary goal is to locate the Date/Time matching the appointment info being passed into the script.
My issue is that our site renders the Date/Time differently depending on how many digits the hour slot contains. In order to maintain spacing, single-digit hours (Such as 3:40pm) include two whitespaces between the date and the time. Multi-digit hours (Such as 11:23am) only include one whitespace.
I need to locate the date/time matching what I'm passing into the function, and then search the corresponding row to ensure that all other appointment info is correct.
We've attempted using .and (Only acts as an assertion, so it doesn't return the element for us), regular expressions (Using /s+ to indicate any number of whitespaces), and for loops, but none of these are returning the element we need.
var apptProvider = new Cypress.Promise(resolve => {
cy.get('.appointments > tbody > tr')
.contains(Cypress.moment(apptInv[2], 'dddd MMMM Do YYYY')
.format('ddd MM/DD/YY')
.toString()+" "+
Cypress.moment(apptInv[3], 'h:mm:ss a')
.format('h:mm A')
.toString(),
)
.parent()
.within(() => {
cy.get('td:nth-child(2)').then($providerText => {
resolve($providerText.get(0).innerText);
});
});
});
apptInv is an array containing the following:
0) Provider Name
1) Office Address
2) Appointment Date
3) Appointment Time
You shouldn't rely on the textual representation to narrow down an appointment here because it's complex, tricky and easily get changed. Instead, you can generate a much simpler unique key that is not affected by any UI/UX change. For example
<tr data-cy='${appointment.provider + appointment.date + appointmentTime}'>
....
</tr>
And then select an appointment with cy.get('[data-cy=....]')
I have a form my drivers complete where part of the form is related to fueling. There is a possibility of 6 separate fuel stops. Each fuel stop line has input where gallons and cost are also included. By default the Cost and Gallons purchased cost is set to $0.00.
My reason for asking assistance:
Occasionally the drivers will inadvertently clicks into one of the date fields on a fueling line and the date will auto populate with the then current date (which can be changed). Then the rest of that line remains all zeros.
I am trying to figure out a validation script that will put the date field back to NULL preferably (or blank) if the Fuel Purchase Cost is at $0.00 as well as the DEF Purchase Cost is also $0.00. BOTH of these items need to be true. Additionally I am not sure how to keep the user inputted DATE if FUEL_PURCH_STOP_1 is >0 AND DEF_PURCH_STOP_1 >0.
NOTE: Fueling will always span 2-3 days.
My end goal is... If a driver clicks in the date field inadvertently, the current date is auto populated. Then if there is a "0" in the both the FUEL_PURCH_STOP_1 AND DEF_PURCH_STOP_1 fields then remove the date from that line. If either one or both of the two fields have a value >0 then I want to keep the user inputted date in the field.
I tried:
var v1 = +getField("FUEL_PURCH_STOP_1").value;
var v2 = +getField("DEF_PURCH_STOP_1").value;
// Set this field's value
if v1 >0 andalso v2 >0) {
event.valueAsString === "WHAT GOES HERE??";
} else {
event.valueAsString === "";
}
Put the following script into the custom calculation for your date field.
var v1 = this.getField("FUEL_PURCH_STOP_1").value;
var v2 = this.getField("DEF_PURCH_STOP_1").value;
// Set this field's value
if (v1 == 0 && v2 == 0) {
event.target.value = "";
}
Using this script, the date entry will only get modified if both of the other fields are zero. It's left as is when the criteria is not met so you don't actually need the "WHAT GOES HERE??" value.
We have a set of processes that need to be performed. Some are done daily, some weekly and some monthly. There is a deadline set up for each process before which it should be completed. We need to send a reminder to the team in the following way.
If the process runs daily and needs to be completed before a particular time, then a reminder should be sent 2 hours before that
If it runs weekly on a particular day then a reminder should be sent at 10AM IST of that particular day
If the process runs monthly and needs to be completed before a particular day, then a reminder should be sent just a day before the end date.
How can I create a VB script for the above task?
The Reminder class doesn't provide any property or method for changing the time. But you may create an appointment item on your calendar for each event (it can be a recurrent item) and set the reminder for the item. The ReminderMinutesBeforeStart property of the AppointmentItem class returns an integer indicating the number of minutes the reminder should occur prior to the start of the appointment. The ReminderSet property allows to set a Boolean value that is True if a reminder has been set for this item. For example:
Sub AddAppointment()
Dim apti As Outlook.AppointmentItem
Set apti = Application.CreateItem(olAppointmentItem)
apti.Subject = "Car Servicing"
apti.Start = DateAdd("n", 16, Now)
apti.End = DateAdd("n", 60, apti.Start)
apti.ReminderSet = True
apti.ReminderMinutesBeforeStart = 60
apti.Save
End Sub
I've created a Google sheet to keep a list of work tasks with a column to track the date on which items are created, and built a script to automatically populate the cells in that column with the day's date when a new line is inserted.
The cell (e.g. G9) that is target of the script uses the following validation formula to make sure that when users change the date, they use a date that is neither a weekend nor in the future:
=and(isdate(G9), weekday(G9,2)<6, G9<=today())
IT ONLY WORKS BUT ONLY IF THE SCRIPT IS RUN ANYTIME AFTER 8:00am ! If I try using it any earlier the cell validation will reject the input!
The script looks like this (curRow is the number of the row that's been added):
// Adds today's date without using =today()
var myrangename = "G"+curRow;
var dateCell = sheet.getRange(myrangename);
var d = new Date();
var dateArr = [];
dateArr[0]=d.getFullYear();
dateArr[1]=d.getMonth() + 1; //Months are zero based
dateArr[2]=d.getDate();
dateCell.setValue(dateArr.join('/'));
(n.b.: I cannot use the script to simply put =today() in the cell because all the entries would change every day. )
WHY DOES IT ONLY WORK AFTER 8:00AM? Is Google somehow running on a different time zone than my computer?? I'm based in the UK, so using BST, but that shouldn't be a problem, shouldn't it...?
Try
var d = new Date();
var d = Utilities.formatDate(d, "GMT+1", "yyyy-MM-dd HH:mm:ss");
I am not sure if google would recognise BST as a time zone, but you could also try
var d = Utilities.formatDate(d, "BST", "yyyy-MM-dd HH:mm:ss");
Thank you for your suggestion, Aprillion. Turns out that a Google Sheets file has its own internal time-zone setting! which in my case was set to American Pacific time (so 8hrs behind)
(You'd think it would pick up the date and time info automatically from Windows, like other applications do!)
To set the sheet's time-zone to the correct one, you need to go to the main menu, click 'File', then 'Spreadsheet settings...', and adjust as necessary.
The script and validation now all work fine.
Thank you all for your help.
I'm working on a program that keeps a list of physical advertisement spots and their reservations (a date range). The program needs to be able to find "open spots" for ads within an ad category.
I have three tables: AdTypes, AdPlaces and Reservations. Currently, I'm implementing a query that searches for reservations where the dates don't collide with the date range the user selected, and returns the AdType items as a list. This method works if every AdType has had an reservation at some point, but it doesn't list AdTypes that are not found in the Reservations table.
The filtering is done in PreProcessQuery of an AdTypes query, as such:
query = query.Where(r => r.Reservations.Any(res => (res.Begindate > Begindate && Enddate < res.Enddate) || (res.Enddate < Begindate && Enddate > res.Begindate)));
How can I "extend" the query so that all those AdTypes that have no reservations would be listed alongside "expired" AdType reservations?
Maybe I'm mssing something, or not quite understanding what you want, but how can you expect see AdTypes that don't exist?
Is it that you want to see the AdTypes that don't have any reservations during the period you're testing for?
If so, I imagine you'd have to use the adType entity as the basis of your screen, not the Reservation entity (with a query based on AdType, not Reservation). That way you can produce a list of AdTypes that don't have any overlapping reservations.
Does that make any sense?