Extended property operations Calendar
twcarnahan opened this issue · 21 comments
We have our current CRM, when we create a Calendar Event, we would like to add an "Extended Property" - single valued string (CRM Unique ID). This would allow us to retrieve only the Calendar Events in question with our CRM. Thank you for your help, Tim:
Have you taken a look at the Extensions snippets in the uwp-csharp-snippets-rest sample? You can post requests for additional samples in User Voice. Have you tried that?
I reviewed the "uwp csharp snippets rest sample" and can not make the jump to the calendar events with extended property. As with aspnet snippets sample, we can create the Caledar Event and but need to add an "Extended value" that relates to our CRM Case value so users can pull up a CRM Case File and All Calendar Events associated.
I do not know what "User Voice" is all about or where/how to access that area.
Vr, Tim:
Currently, we create an event using the below:
// Add the event.
Event createdEvent = await graphClient.Me.Events.Request().AddAsync(new Event
{
Subject = Resource.Event + guid.Substring(0, 8),
Location = location,
Attendees = attendees,
Body = body,
Start = startTime,
End = endTime
});
If we could add our own "Extended Property" we would do it here "CalenderEventCRMCaseID = CRMCaseId" and then we could easily query to get all Calendar Events where CRMCaseId = "xxxxxxx".
Vr, Tim:
Open extensions might help address your scenario. Could you read this blog post on it and let me know if you can use them? https://dev.office.com/blogs/adding-customer-data-to-resources-in-Microsoft-Graph-preview
This seems to touch on what we need --- but, we were under the impression that the "extended property" would be part of the calendar event; is that what is happening here?
From what we know and understand, we can Post and Get using the Graph Libraries - how do we add a field so that it is tied to newly and all calendar events we create?
Vr, Tim:
It sounds like you need a schema extension. This would allow you to add your new property to all existing and newly created calendar events. You'd post a new schema definition that targets the Event type and that adds whatever properties you want to add. Note that you have to include a type for each new property that you create. The example shows how to do this with the Group type, but it shouldn't be too difficult to extrapolate that to an event. Note that this feature is still in preview, so you have to use the /beta endpoint when you use these types of properties.
If all we have to do is POST this below once, then use the above "Add the Event" the yes it seems logical and will give it a try.
POST https://graph.microsoft.com/beta/schemaExtensions
Content-type: application/json
{
"id":"graphlearn_courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Event"
],
"properties": [
{
"name": "courseId",
"type": "Integer"
},
{
"name": "courseName",
"type": "String"
}
]
}
That's my understanding. There is also an example in the UWP REST snippets sample.
Yes, I see the concept -- the UWP REST snippets is very different than how this JSON is used in this snippets example whereas it does not use the Microsoft Graph Library. All of our code to this point uses the MS Graph Library so this is another concept on how we pass the graph client and build our query statements. (I think I said that correct)
Vr, Tim:
Unfortunately this feature isn't yet in the Graph Library because it is still in preview. That's why you have to use raw REST queries. Let us know how this goes for you.
That's what I was trying to say "Raw REST queries" -- :)
Ok - we will give it a run - thank you for your direction and help, Tim:
We looked at doing this and it seems as so far a major shift from our MVC 5 environment - Can Microsoft put a resource on this as so we can then integrate our solution. Many thanks, Tim:
Could you make this request on Stack Overflow? Be sure to tag it with MicrosoftGraph, explain your scenario and the problems you're having with the extensions API. You could then add the link to your question to this thread, and I could follow up with someone who might be able to help you on Stack Overflow.
Were you able to get some resources to help with this issue - thank you much, Tim:
It looks like a good person is already on that thread. It looks like you're asking for us to add Extensions samples to the ASP.NET snippets sample. I'll put that work into our backlog so that we can prioritize it. I'll close this for now, since it's more of a feature/resource request than an issue with the sample.
Hello,
This really is a problem with Microsoft Graph Library as is should support this but it does not yet the documentation says it does. The V.2 Endpoint is in beta for using this feature -- so, it's not a feature request - it's part of the Microsoft Graph Library. Smile - I hope I stated that correctly. Basically, we would have to write code without using the Microsoft Graph Library and use the JSON Library for creating the calendar and other things we need to use this capability of the Microsoft Graph - I think we both understand that concept. This has put our project at a standstill and really should be supported - we need support from Microsoft on this as not to "put on the scale of priorities". Please ask your management to help get this done for us so we can count on Microsoft support. Much Appreciate your time, Tim:
https://dev.office.com/blogs/adding-customer-data-to-resources-in-Microsoft-Graph-preview
--- I've added a link here to go Full Circle with this issue. Thanks for your help and lets get this one done for the team!!!
Vr, Tim:
It looks like you have a choice between using Extended Properties (which Marc is suggesting on Stack Overflow and which is available in the SDK) or open extensions, which aren't yet available in the SDK but will be eventually.
One question for you is whether applications other than the one you're writing will need access to the Outlook MAPI properties that are not already exposed through the Microsoft Graph. If that's the case, then Extended Properties would likely be your best option. If that's not the case, then it would likely be best to use Open Extensions, which will be available in the SDK in the near future.
See this document for more context:
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/opentypeextension
Look especially at the section titled, "Use open extensions (for Outlook resources) or extended properties?"
The problem is that there is a conflict when using both the Newton Library and the Microsoft Graph library on the same page - this is why I ask if Microsoft could put the example together. See Microsoft Graph Library merely just rewrites the JSON in Strong Type. So, while you try to use certain methods, they would conflict with each other - so you have to use two separate paths to the solution as I understand it. Can Microsoft add the example here in this snippet?
Vr, Tim:
Could you try using this code to create an extended property?
// https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_post_events
// https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/singlevaluelegacyextendedproperty_post_singlevalueextendedproperties
// https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/extended-properties-overview
var myEvent = new Microsoft.Graph.Event();
myEvent.Subject = "Class: how to use StackOverflow like a pro";
myEvent.Body = new ItemBody() { ContentType = BodyType.Text, Content = "In this course, we’ll learn how to StackOverflow. };
myEvent.Start = new DateTimeTimeZone() { DateTime = "2017-05-29T12:00:00", TimeZone = "Pacific Standard Time" };
myEvent.End = new DateTimeTimeZone() { DateTime = "2017-05-29T13:00:00", TimeZone = "Pacific Standard Time" };
myEvent.Location = new Location() { DisplayName = "Online" };
myEvent.SingleValueExtendedProperties = new EventSingleValueExtendedPropertiesCollectionPage();
var myCustomIdentifier = "String {66f5a359-4659-4830-9070-00040ec6ac6e} Name courseId";
var myCustomExtendedProperty = new SingleValueLegacyExtendedProperty()
{
Id = myCustomIdentifier,
Value = "1234567"
};
myEvent.SingleValueExtendedProperties.Add(myCustomExtendedProperty);
// Create the event with the extended property in the service.
var mySyncdEvent = await graphClient.Me.Calendar.Events.Request()
.AddAsync(myEvent);
// Get the event with the extended property.
var mySyncdEventWithExtendedProperty = await graphClient.Me
.Calendar
.Events
.Request()
.Expand($"singleValueExtendedProperties($filter=id eq '{myCustomIdentifier}')")
.GetAsync();