2013-06-24

After setting up my environment for SharePoint app, I was thinking about writing my first app for SharePoint. After a long weekend thinking to find my first  “Hello World” kinda app, I came across this Color Calendar solution on one of my great friend Mark Wilson’s blog. Kindly, he has agreed to use his idea to try it on my first SharePoint app and here is it below…

Just before going into the details, please find the environment details which I used for the Color Calendar app.

Environment Details: (Setup – Configure App environment)

  • Web Application  and a Root Team Site (ex: http://win-2j3idcdeuh6/)
  • App Catalog site the above web application (ex: http://win-2j3idcdeuh6/sites/apps/_layouts/15/start.aspx#/AppCatalog/Forms/AllItems.aspx)
  • App DNS (ex: sp.apps.local)
  • App DNS Prefix (ex: spapps)
  • Visual Studio 2012 with the SharePoint 2013 App add-ins

What is Color Calendar?

Step 1:

  • Create a new Project “ColorCalendar” with the option “App for SharePoint 2013”
  • Select the Site and the Type of hosting as below

  • Note: The types of App hosting details can be found here

Step 2:  Create a Custom List based on the calendar list

  • Right Click on the “ColorCalendar” project and Add a new List

  • Click Next and Select the Custom List template option as “Calendar” as below

  • Click Finish.

  • Amend the List Schema to include a Calculated field as below
  • <Field Type="Calculated" ID="{2A55D341-73C9-4df9-8BC6-F9A754A08F82}" Name="CategoryTitle" DisplayName="CategoryTitle" ResultType="Text" ShowInDisplayForm="FALSE" StaticName="CategoryTitle">
            <Formula>= "|||" &amp; [Category] &amp; "|||" &amp; [Title]</Formula>
            <FieldRefs>
              <FieldRef Name="Title" />
              <FieldRef Name="Category" />
            </FieldRefs>
          </Field>

     

  • Amend the “Calendar” view as below
  •   <ViewData>
              <FieldRef Name="CategoryTitle" Type="CalendarMonthTitle" />
              <FieldRef Name="CategoryTitle" Type="CalendarWeekTitle" />
              <FieldRef Name="Location" Type="CalendarWeekLocation" />
              <FieldRef Name="CategoryTitle" Type="CalendarDayTitle" />
              <FieldRef Name="Location" Type="CalendarDayLocation" />
            </ViewData>

     

  • Amend the Default.aspx to include a webpart zone (to display the Calendar – ListView webpart) and a JS section to implement the ColorCalendar functionality
  • Amend the App.Js to include the ColorCalendar functionality

  • Amend the Page element.xml to include the ListView Webpart as below

Step 3 : Compile the solution

  • Compile and Publish the project.
  • The output will be “ColorCalendar.app”

Step 4: Publish the app to the catalog site

  • Go to the App Catalog site (ex: http://win-2j3idcdeuh6/sites/apps)
  • Click “App for SharePoint” -> “New app” -> Upload the “ColorCalendar.app”

  • Click Save

Step 5: Add the ColorCalendar app into the site

  • Go to the Site (ex: http://win-2j3idcdeuh6/) and Click “Site Contents”
  • Click “Add an App” option

  • Click the “ColorCalendar” app and Click “Trust It”

  • App is installed and ready to use

Step 6: Click the installed app…

  • Add an event to the Calendar and there you go….we have a Color Calendar…

Conclusion :

Sample Code:

And Once again, I would like to thank my friend and colleague Mark Wilson for his support and allowing me to use his code on this blog. More details about the ColorCalendar script can be found here.

About the author 

Balamurugan Kailasam