I'm using the following code to create an All Day Event in a SharePoint calendar:
newitem = listobject.Items.Add()
guid = System.Guid.NewGuid()
newitem["Name"] = "All Day Event " + guid.ToString()
newitem["Title"] = "All Day Event " + guid.ToString()
newitem["Start Time"] = System.DateTime.Now.Date
newitem["End Time"] = System.DateTime.Now.Date
newitem["Description"] = "Created by Automation Script"
newitem["Location"] = "Location " + guid.ToString()
newitem["UID"] = guid
newitem["All Day Event"] = 1
newitem.Update()
print newitem["Created"]
However, when I query for the Created date of the created item (as in the last line ), it gives me the time in UTC. But in case of a Normal event or a recurrent event it gives me the local time. I tried to find the Kind property of the DateTime object, but it is set to Unspecified. The same problem occurs even if an All Day Event is created through the SharePoint site (manually). So I came to a conclusion that there is nothing wrong in the code. Please help me.
See
SO SharePoint - all day events behave differently in CAML query
Related
I'm using AVPlayerViewController in order to play an HLS file, however the start time is always 00:00 and the end time is the duration of the event from the HLS manifest.
Instead I would wish to display the start time of the event and the end time of the event.
I found that can be used: AVKitMetadataIdentifierExactStartDate / AVKitMetadataIdentifierExactEndDate
But looks like when I create an AVMutableMetadataItem and I try to assign as identifier the AVKitMetadataIdentifierExactStartDate it doesn't exist. So I'm kind of stuck.
Anyone has any idea?
After few days of researches, I found that this can be achieved creating a AVMutableMetadataItem, assigning them as identifier an AVMetadataIdentifier(AVKitMetadataIdentifierExactStartDate) then as value you can just add the start time as date and cast everything as NSCopying & NSObjectProtocol.
Once you setup both properties you can append to the player.currentItem.externalMetadatas the new metadataItems that you just created as array of metadataItems.
Full example below:
//Add start date
let item = AVMutableMetadataItem()
item.identifier = AVMetadataIdentifier(AVKitMetadataIdentifierExactStartDate)
item.value = startDate as? NSCopying & NSObjectProtocol
let metadataItem = item.copy() as! AVMetadataItem
//Add start date
let endTimeItem = AVMutableMetadataItem()
endTimeItem.identifier = AVMetadataIdentifier(AVKitMetadataIdentifierExactEndDate)
endTimeItem.value = endDate as? NSCopying & NSObjectProtocol
let endTimeMetadataItem = endTimeItem.copy() as! AVMetadataItem
var metadataItems = [AVMetdataItem]()
metadataItems.append(metadataItem)
metadataItems.append(endTimeMetadataItem)
self.player.currentItem?.externalMetadata = metadataItems
I'm finding that when I read the GlobalAppointmentID of a recurring event in Outlook via my Excel-VBA code, things start acting odd.
Here's part of the code that I've been using to try to understand the root cause of this behavior:
For Each otItem In resCal
If otItem.Class = olAppointment Then
Set cItm = otItem
If calItem.Subject = "Coffee Date" Then
Debug.Print "Coffee orig " & cItm.Start
Debug.Print "Coffee orig 1.1 " & cItm.Start
Debug.Print cItm.GlobalAppointmentID
Debug.Print cItm.GlobalAppointmentID
Debug.Print "Coffee orig 1.5 " & cItm.Start
End If
End If
Next otItem
This produces the following output:
Coffee orig 4/16/2015 10:00:00 AM
Coffee orig 1.1 4/16/2015 10:00:00 AM
[Global Appointment ID redacted, but identical]
[Global Appointment ID redacted, but identical]
Coffee orig 1.5 2/19/2015 10:00:00 AM
4/16 is the instance of the recurring event that I would like to record. However, when I call the GlobalAppointmentID property, it changes the value of the .Start property to that of the first instance of the recurring event. I've tested and can implement a workaround that involves me storing the start date in a variable before calling GlobalAppointmentID, however I would like to try to diagnose and fix the root cause of the issue to ensure that it isn't causing any problems that I haven't noticed yet. Can anyone shed some light on what is causing this issue?
Thanks!
the problem does not occur when I call the AppointmentItem by index instead of looping via For Each
I'd recommend using the for loop instead and releasing the object as soon as possible. This is particularly important if your code attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. Declare an object in the function scope (loop scope) and set it to Nothing to release the reference to the object as soon as possible.
I recently took another look at my code and determined the source of the problem. Here’s the snippets of code that were causing the problem:
With oItms
.Sort "[Start]", False
.IncludeRecurrences = True
End With
Set rCal = oItms.Restrict("[Start] >= '" & CStr(date) & "'")
With rCal
.Sort "[Start]", False
.IncludeRecurrences = True
End With
Specifically, running the “.Sort” and the “.IncludeRecurrances” on rCal without calling the “.Restrict” method caused the problem. I determined that the 2nd “With” was redundant as is, so I removed it. I can now call any property in any order, without having to worry about the values changing.
I am trying to create an anonymized schedule for the conference rooms on our floor via Excel VBA.
The source data is stored in different Outlook calendars (every room has its own) and I got access to them via the "shared calendar" functionality of Outlook.
The problem I am currently having is fully automating the data retrieval process. I got everything else working fine, however, it requires the user to manually select the (currently) five different calendars from a small pop-up window, which is rather tiresome.
I have tried using the GetDefaultFolder(olFolderCalendar).Items approach, but this only seems to work for the local calendar not shared ones from the network (Exchange).
Is there a way to address these room calendars directly so that I can automate my process?
best regards,
daZza
Here's my current code, cut down to the relevant parts:
Set olNS = olApp.GetNamespace("MAPI")
For x = 1 To 5
Set myCalItems = olNS.PickFolder.Items
With myCalItems
.Sort "[Start]", False
.IncludeRecurrences = True
End With
StringToCheck = "[Start] >= " & Quote(StartDate & " 12:00 AM") & " AND [End] <= " & Quote(EndDate & " 11:59 PM")
Set ItemstoCheck = myCalItems.Restrict(StringToCheck)
' Do stuff with every item in "ItemstoCheck"
' ...
' ...
' ...
Next
Have you looked into the Namespace.GetSharedDefaultFolder method?
Is it possible to create a date only field in XPages? I have tried the following in the querySaveDocument event but the field still ends up with a time portion of 00:00:00
var notesDoc:NotesDocument = document1.getDocument();
var dt:NotesDateTime = session.createDateTime(#Today());
dt.setAnyTime();
notesDoc.replaceItemValue("MyDateField", dt);
It is not completely clear what you are trying achieve.
You can put an EditBox component on your XPage, then go to the "Data" tab. From there you can change the formatting from String to Date. More options should appear on how to format the date in the field. It will handle passing the date to the back end document.
If it is you want to write directly to the back end document, then here is a page listing samples on working with NotesDateTime.
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesDateTime_sample_JavaScript_code_for_XPages
Here is code by Sven:
ndt = session.createDateTime(ndt.getDateOnly());
item.setDateTimeValue(ndt);
error in date items, daylight Saving
Update:
I had to do the same thing and found out that it's working this way in Java agent in 8.5.2FP3:
DateTime dt = session.createDateTime(new java.util.Date());
dt.setAnyTime();
doc.appendItemValue("DT", dt);
I'm trying to find an effective method of filtering Sharepoint lists based on the age of an item. In other words, if I want to find list items that are 7 days old, I should be able to build a filtered view on the data.
There is a hack to build a "Today" field that works, but doesn't filter properly.
Does anyone have any good ideas?
If you want to filter only items that are less than 7 days old then you just use
Filter
Created
is greater than or equal to
[Today]-7
Note - the screenshot is incorrect.
[Today] is fully supported in view filters in 2007 and onwards (just keep the spaces out!) and you only need to muck around with calculated columns in 2003.
Have you tried this: create a Computed column, called 'Expiry', with a formula that amounts to '[Created] + 7 days'. Then use the computed column in your View's filter. Let us know whether this worked or what problems this poses!
In the View, modify the current view or create a new view and make a filter change, select the radio button "Show items only when the following is true", in the below columns type "Created" and in the next dropdown select "is less than" and fill the next column [Today]-7.
The keyword [Today] denotes the current day for the calculation and this view will show as per your requirement
Warning about using TODAY (or any calcs in a column).
If you set up a filter and have JUST [Today] it it you should be fine.
But the moment you do something like [Today]-1 ... the view will no longer show up when trying to pick it for alerts.
Another microsoft wonder.
Pass Today as value as mentioned below in $viewQuery property :
$web = Get-SPWeb "http://sitename"
$list = $web.Lists.TryGetList($listtitle)
write-host "Exporting '$($list.Title)' data from '$($web.Title)' site.."
$viewTitle = "Program Events" #Title property
#Add the column names from the ViewField property to a string collection
$viewFields = New-Object System.Collections.Specialized.StringCollection
$viewFields.Add("Event Date") > $null
$viewFields.Add("Title") > $null
#Query property
$viewQuery = "<Where><Geq><FieldRef Name='EventDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'><Today/></Value></Geq></Where><OrderBy><FieldRef Name='EventDate' Ascending='True' /></OrderBy>"
#RowLimit property
$viewRowLimit = 30
#Paged property
$viewPaged = $true
#DefaultView property
$viewDefaultView = $false
#Create the view in the destination list
$newview = $list.Views.Add($viewTitle, $viewFields, $viewQuery, $viewRowLimit, $viewPaged, $viewDefaultView)
Write-Host ("View '" + $newview.Title + "' created in list '" + $list.Title + "' on site " + $web.Url)
$web.Dispose()