In this post, our Windows Phone Development MVP, Vikram Pendse talks about a feature of calling a number from Calendar Appointment.
Windows Phone device gives you a lot of features and functionalities which you can leverage in your daily life. Let it be Camera, Music, Socials, Games, Emails etc. “Calendar” is one of the must have features on any phone. Enterprise and Business people just can’t live without it. Usually Lync Meetings/Other Meetings syncs up with Calendar. But there are lot of other scenarios in life which are more personal.
Let us take an example: Your family member is undergoing some Medical treatment and you need to collect Blood Report. You can very well set a reminder on your phone or some short/sticky notes. Now if you want to call the Lab and wish to know status of the report. Usually you go to People Hub or somewhere in the Notes or old SMS reference and try to get Numbers. How about I can attach a Telephone Number to the Appointment and more over how about I can place a call from there itself. Saves lot of Time and Navigation. But is it possible to do such things? On device yes! Manually you can do it on device. Programmatically? Or via some App? That is what I am going to talk about in the below article.
This article is about SaveAppointmentTask in Windows Phone 8 SDK. This is pretty handy and you can save appointments from your application. Basically it is a Launcher, Those who don’t know about Launchers & Choosers in Windows Phone, I recommend to read more here (MSDN Link)
SaveAppointmentTask comes handy and we can customize various parameters and aspects programmatically via C#. First let us see how we can get SaveAppointmentTask.
SaveAppointmentTask is a sealed Class comes from Namespace Microsoft.Phone.Tasks. We can create new instance of SaveAppointmentTaks and will be then able to play with its various attributes. Let’s see the Home Screen first. There are 2 Buttons with a Result Textblock which shows the recently added Appointments once you click on Load Appointments, but in this article our focus will be on “Take Appointment”, so here we will be looking at adding a new Appointment.
Now let’s see the Code Snippet here which will Display up the Appointment Wizard from our application and we can either Edit or Delete it. Currently we have set the entire attributes from Code and we can just Save and let it go, here is the snippet:
var saveAppt = new SaveAppointmentTask();
saveAppt.StartTime = DateTime.Now.AddHours(1);
saveAppt.EndTime = DateTime.Now.AddHours(2);
saveAppt.Subject = "Call and Check Blood Reports is ready or not at Ruby Hall";
saveAppt.Location = "Pune";
saveAppt.Details = "tel:+911234567890";
saveAppt.IsAllDayEvent = false;
saveAppt.Reminder = Reminder.FifteenMinutes;
saveAppt.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;
Here StartTime and EndTime specifies the duration of Appointment. Subject gives the details about appointment where Details gives the metadata. Rest of the parameters like “IsAllDayEvent”, “Reminder”, “AppointmentStatus” depends on your business requirement.
This will add Appointment to your Calendar and it will look like this on device:
Once you tap on Calendar and on the particular Appointment
and click on this appointment
Now Just Tap on any Phone Number and it will ask you whether you want to Edit the Number or wish to go ahead with the same
Now Call will actually put a call to given Number and you now don’t need to go anywhere to hunt the Phone Number since its now part of your appointment itself. Saves lot of time especially in case of important appointments or business activities. So on call it will look like following
SaveAppointmentTask gives you the default window where like other Appointments, you can always edit the things you want in the Appointment and save or delete the same. So we saw a unique combo of SaveAppointmentTask and URI. We can take it to next level by adding other complex operations like Maps, Mails, URLs, etc. All you need to do is set the “Location” property or “Details” property of SaveAppointmentTask Class.
“Location” property is String Property and instead of just giving Phone Number or Location as pure text, we can play with things like URLs, Email Address like shown below
saveAppt.Location = "http://maps.google.com/maps?q=18.58073000,73.73740000";
saveAppt.Location = "view-source:http://en.wikipedia.org/wiki/URI_scheme";
saveAppt.Location = "tel:+919922210345";
saveAppt.Location = "mailto:email@example.com";
Maps URL string will redirect to the default Internet Explorer Browser and it will open the given location in the string.
View Source will show the URL given in the string inside a default Internet Explorer Browser.
For “tel:” it will open a window for confirmation asking Edit this Number and give with Call and Cancel Button, On clicking on Call it will place a call to selected Number.
We can leverage “mailto” URI scheme for sending a quick email via appointment. In more advance case we can even set Subject and Body as well but that will be too complicated and tricky! Here is the example :
Hope you like this quick short article on SaveAppointmentTask and I am sure you will leverage this feature in your ongoing App Development.
About Guest Blogging
South Asia MVP Award Program introduces Guest Posts by the MVPs from the region. These posts would help readers to be in touch with the recent trends in technology and be up-to-date with knowledge on Microsoft products.
nice work Pendse sir...