Featured Posts

SharePoint Provider Hosted Apps Tips and Tricks - Introduction I am starting a tips and tricks blog series on building Provider Hosted Apps in SharePoint. All posts in these series will be categorized appropriately and can be referenced from this link: http://www.greggalipeau.com/category/sharepoint-2013/apps/sharepoint-provider-hosted-apps-tips-and-tricks-series/ So,...

Read more

A Better Enhanced SharePoint 2010 Floating Ribbon SharePoint 2010 has issues with its scrolling because of the way it implemented the fixed ribbon. Before we look into these issues (and a workaround) let's first try to understand what SharePoint is doing....

Read more

Tips and Tricks for setting up a SharePoint 2010 development... While SharePoint 2010 is similar to SharePoint 2007, there are many tips and tricks to setting up a proper SharePoint 2010 development environment. Some of these are the same as SharePoint 2007 and some...

Read more

Developing SharePoint WebParts using User Controls... If you’ve read my blogs before, then you probably know I am a fan of WSPBuilder (http://www.codeplex.com/wspbuilder). I like the intuitive nature and flexibility of the product. It really helps with...

Read more

Cleaning up your WebPart Gallery Deploying webparts in SharePoint can be difficult (when you are learning) because of the many ways to do it. You can manually add webparts to the WebPart gallery, you can add WebParts through features...

Read more

  • Prev
  • Next

SharePoint Provider Hosted Apps Tips and Tricks (part 3) – loading SharePoint js files and context

Category : SharePoint Provider Hosted Apps Tips and Tricks Series

The SharePoint provider hosted app runs on the JSOM (javascript object model) concept. Well, it can use CSOM too (client object model), but I am really embracing the JSOM programming methodology in my apps. But, there is one small problem… there is no “ScriptLink”. This makes sense. “ScriptLink” is a SharePoint functionality that runs on a SharePoint server. Provider Hosted apps run on any web server you want. So, it can’t find the “ScriptLink” reference on the server you run the provider hosted app on.

What is a “ScriptLink”? A “ScriptLink” is a great javascript reference model in SharePoint that lets you load one js file after another one is finished (ex: <SharePoint:ScriptLink name=”sp.js” runat=”server” LoadAfterUI=”true” Localizable=”false” />). This is very important in SharePoint because some javascript files assume the previous one has finished to load particular variables.

So, how do you do this without ScriptLinks. Well, I found the answer while reading code from the Kudos App that Microsoft put out to show a real life example of a provider hosted app: http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2012/08/19/real-world-apps-for-sharepoint-2013-kudos-part-1.aspx

All you have to do is this:


var hostweburl, appweburl;
    //load the SharePoint resources
    function loadSharePointJs() {
        //Get the URI decoded URL.
        hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
        appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));

        if (hostweburl) {
            // The SharePoint js files URL are in the form:
            // web_url/_layouts/15/resource
            var scriptbase = hostweburl + "/_layouts/15/";

            //load all appropriate scripts for the page to function
            $.getScript(scriptbase + 'SP.Runtime.js', function () {
                $.getScript(scriptbase + 'SP.js', function () {
                    $.getScript(scriptbase + 'SP.RequestExecutor.js', registerContextAndProxy);
                    $.getScript(scriptbase + 'init.js', function () {
                        $.getScript(scriptbase + 'SP.UserProfiles.js', function () { });
                    });
                });
            });
        }
    }

Notice that each javascript load calls a function to load the next javascript. So, any variables that a previous one sets, the next one will be able to use.

Note: if you have issues figuring out how I got the hostweburl and appweburl in my code above, I suggest reading the first two parts of this blog series as they build on each other: http://www.greggalipeau.com/category/sharepoint-2013/apps/sharepoint-provider-hosted-apps-tips-and-tricks-series/

Extra bonus tip and trick:
Notice the callback to “registerContextAndProxy”. That is a function you can use to load the SharePoint context.


function registerContextAndProxy() {
    context = new SP.ClientContext(appweburl);
    var factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
    context.set_webRequestExecutorFactory(factory);
}

Now you can use the “context” variable anywhere in your javascript files. This is very important because the “context” is the key to writing JSOM and calling back to SharePoint.

SharePoint Provider Hosted Apps Tips and Tricks (part 2) – SPAppWebUrl

Category : SharePoint Provider Hosted Apps Tips and Tricks Series

This one drove me crazy when trying to figure it out.

All I wanted to do was get the SPAppWebUrl out of the querystring. But, it wasn’t there. Every demo I could find mentioned it. Why wasn’t it there? Arghhh. I noticed in this post: http://msdn.microsoft.com/en-us/library/jj163816.aspx Microsoft had this comment:
“If there is no app web, the portion &SPAppWebUrl={AppWebUrl} is not present.”

So, what does that mean? I created a Provider Hosted App project in Visual Studio. That created two projects, the App project and the Web Project. Well, it turns out you have to do something in the App Project for SharePoint to think you have an app web. Turns out, you can do anything – add a list, add a content type, basically anything. Just right-click on the App project and choose a new SharePoint item.

Why did they do this – well, they probably thought there is no reason to get the SPAppWebUrl. I mean, this parameter is just used to get the context to SharePoint (which I will talk about in my next post). So, I assume in their minds they said – if you don’t do anything with SharePoint, you don’t need this parameter.

However, there are a couple flaws in that theory. I was creating a project where the only reason I needed the context was to do a PeoplePicker type of lookup on the user profiles. So, technically I didn’t need to create any SharePoint items. So, I just created a list called “Test” to get around this issue and walla, the SPAppWebUrl magically appeared in my query string.

In the next post in this series you will learn about why this is important to get the SharePoint context in javascript.

SharePoint Provider Hosted Apps Tips and Tricks (part 1) – query strings

Category : SharePoint Provider Hosted Apps Tips and Tricks Series

Query strings are very important in the SharePoint Provider Hosted App model. You need SharePoint to tell your external website important information about where in SharePoint it is coming from.

Setting Query Strings

When creating a Provider Hosted App in SharePoint two projects are created. The first project is the App project that builds the manifest for SharePoint. The second project is the Web Project (i.e.: the website that gets launched and lives outside of SharePoint).

To set the correct query strings go to the App project – AppManifest.xml

You will see a QueryString box there. It probably already has the StandardTokens set. I also like to set the Title (so I can use it later in the Chrome). So, I update it to this: {StandardTokens}&SPHostTitle={HostTitle}

Whats in the Standard Token?

This combines five other tokens. It initially resolves to SPHostUrl={HostUrl}&SPAppWebUrl={AppWebUrl}&SPLanguage={Language}&SPClientTag={ClientTag}&SPProductNumber={ProductNumber}. Then each of these tokens resolves.

IMPORTANT: If there is no app web, the portion &SPAppWebUrl={AppWebUrl} is not present. I will cover this more in my next post. But, it is basically saying if you haven’t done anything special to the app web, it won’t provide this.

What are the other Tokens?

No need to re-document, you can read about them here: http://msdn.microsoft.com/en-us/library/jj163816.aspx

Reading Query Strings

You will need a javascript function to parse the query string:


    function getQueryStringParameter(paramToRetrieve) {
        var qsSplit = document.URL.split("?");
        if (qsSplit.length > 1) {
            var qs = document.URL.split("?")[1];
            var params = qs.split("&");
            var strParams = "";
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve)
                    return singleParam[1];
            }
        }
    }

Then you can get the QueryString parameters in your javascript code like this:


 var hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
 var  appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
This knowledge will be very useful in the following posts.

SharePoint Provider Hosted Apps Tips and Tricks – Introduction

Category : SharePoint Provider Hosted Apps Tips and Tricks Series, featured

I am starting a tips and tricks blog series on building Provider Hosted Apps in SharePoint. All posts in these series will be categorized appropriately and can be referenced from this link: http://www.greggalipeau.com/category/sharepoint-2013/apps/sharepoint-provider-hosted-apps-tips-and-tricks-series/

So, I’ve now built two apps in the office store:

  1. Office app – MindMapper: http://office.microsoft.com/en-us/store/mindmapper-WA103953725.aspx?redir=0
  2. SharePoint Hosted app – UltimateSlider: http://office.microsoft.com/en-us/store/ultimate-slider-WA103984742.aspx?queryid=f7864eec-5256-46bc-b6a9-91bb32b73bbf&css=sharepoint&CTT=1

So, my next foray is a SharePoint Provider hosted app. Why you ask? Well, here is why:

When I built the Office App I loved that I could change/tweak/enhance the app, on my own website, whenever I want, without resubmitting the app to the app store. However, since the SharePoint Hosted App is completely bundled in the submission to the app store, I have to resubmit every time I want to make a change. But… SharePoint Provider Hosted Apps are very similar to Office Apps – they run in their own website and use oAuth to connect to SharePoint. I will get that great advantage of being able to upgrade my app in my own website and the users will see the changes right away.

Love the model.

However, as I’ve learned, there are a lot of gottcha’s while building SharePoint Provider Hosted Apps. So, I am going to document any tips and tricks I learn along the way in a series of blog posts. Maybe they will help others. But, I know they will help me to remember what I’ve learned along this journey.

Enjoy and keep your eyes out for my first tip and trick (should be up in about 5 minutes).

Link to series: http://www.greggalipeau.com/category/sharepoint-2013/apps/sharepoint-provider-hosted-apps-tips-and-tricks-series/

Adding Office/SharePoint Apps to the Office App Store Seller Dashboard

Category : Office Apps

The following are lessons I learned when deploying my first app for Office in the Seller Dashboard. My app was an Office app (but, it looks like the steps are similar for SharePoint). I wish I would have known more about the logos I needed, screenshots, support websites, etc… when I started. So, these are really notes for me for future apps that might help others out too.

Apps are deployed through the Seller Dashboard at https://sellerdashboard.microsoft.com.

  1. Account Approval
    1. It can take around a week (at the time of writing this) to get an account approved. I had all my code ready to go for app approval and didn’t realize I had to wait to get my account approved.
    2. Is this a company or individual account? http://msdn.microsoft.com/en-us/windows/apps/jj657972.aspx
    3. Do you have an icon (96 x 96 pixels)?
    4. Do you have a good description ready?
    5. Do you have a website to explain your company or yourself?
      1. App preparation
        1. What kind of app is this?

          SharePoint, PowerPoint, Excel, Excel Embedded, Word, Project

          Note: You can have a single app that is in a Task Pane (PowerPoint, Excel, Word, Project). But, Excel Embedded and SharePoint have to be created with seperate manifests.

        2. Where are you going to host your app? Apps are just html5 webpages. I suggest Azure if you don’t have a website ready. http://www.windowsazure.com
        3. Is your site https? Azure has https by default ready.
        4. Make sure the app package has the same provider name in the manifest as submitted via your account on the Seller Dashboard.
          1. App deployment
            1. App must be approved. Account for some time for this.
            2. Do you have an icon (96 x 96 pixels)?
            3. Have a good description ready?
            4. Do you know your price point?
            5. Have your app package ready (xml file from compiled solution).
            6. Do you have screenshots ready (514 x 384 pixels)?
            7. Do you have a support document website for the app?

          Lastly, please understand the approval process: http://msdn.microsoft.com/en-us/library/office/apps/jj591603

SharePoint 2013 ‘Apps’ – Step Forward or Confusing Message

1

Category : Apps, Office Apps, SharePoint 2013

Everything is an App now a day – iOS Apps, Android Apps, Windows 8 Apps, FaceBook Apps and now SharePoint Apps. But, what is an App in SharePoint. In its simplest form an App in SharePoint is just a separate web page using oAuth to securely connect to SharePoint. It’s a pretty simple concept with a lot of oAuth work in the background to keep that secure connection.  You can think of SharePoint as your “Host Web” and your App as your “App Web”. While navigating around SharePoint you will see a link for an app, when you click it you will navigate to the App on the App Web. The other interesting thing SharePoint did was keep the chrome (look and feel) style of SharePoint intact as you navigate to this App site.

In addition to the separate web site concept, they also have something called an App Part. An App Part is just an iFrame. So, in essence, it is just like the App I described earlier. It just uses an iFrame to show the App webpage in a frame view. Now, to give Microsoft credit, they did do some pretty creative stuff to this iFrame to minimize some of the downsides of iFrames (such as dynamic sizing and scroll bar behavior – i.e.: they allow you to size without the scroll bar showing in the frame). But, it’s still an iFrame – we will get into this later in this article.

When I first heard of this App model I was very excited. I can think of many, common scenarios in SharePoint development were this will be helpful. Just the other day I had to build a HelpDesk application in SharePoint 2010. This consisted of piecing together WebParts, custom code, workflows, etc… into a new SharePoint site collection. If I had to build that same application in SharePoint 2013 I would use the App model. I would build the HelpDesk application in ASP.Net MVC and I would still store the HelpDesk Requests in SharePoint using CSOM (SharePoint’s javascript API) to interact between the App and SharePoint. That’s truly what Apps were meant to be.

Now, here are the downsides of Apps – Microsoft’s “Messaging”. No, how can that be? Microsoft doesn’t give confusing messages to people, never. I mean, they didn’t just promote Sandbox solutions as the next big thing in SharePoint 2010 and then depricate them in SharePoint 2013. This doesn’t sound like Microsoft at all. But, yes, believe it or not, Microsoft’s messaging is very confusing on this perspective. Once again, Microsoft has divided how they speak to end users vs. how they speak to developers. To end users, everything is an App. They have plastered the word ‘App’ all over SharePoint 2013. They’ve deliberately chose to force the App terminology on the end user. However, an App is really defined by how the functionality is pieced together in code by the developer. For example: the developer still has the choice to build full trust Web Parts vs. App Parts. Can you see how this is going to get confusing yet? Upper management, business users, etc… are going to ask developers for Apps. But, the developer has to make the architectural choice of when an App is the right solution vs. something else like a WebPart.

So, you might ask yourself – why not just always build Apps? There are actually many reasons. But, let’s focus on one. Remember earlier when I told you an App Part (which Microsoft is telling end users is just like a WebPart) is really an iFrame. Well, that has disadvantages. I just came back from the SharePoint 2013 conference and I had a chance to talk to the development team of SharePoint. I mentioned I was hugely disappointed in the iFrame concept in the App Part. They looked shocked when I said that (I guess they were expecting praise the whole conference – lots of people there that just drink the SharePoint Kool Aid). They gave me the song and dance about how iFrames are the only way to keep the separation of Apps and the Host SharePoint site securely (which I completely understand). They also challenged me to show them examples of how it doesn’t work. It took me about a millisecond to show an example of a WebPart I’ve built in the past. I recently built a WebPart whose main functionality is to manipulate the html outside the WebPart to create Tabs. Guess what – you can’t manipulate the html outside an iFrame (well, you can, but you need special code outside the iFrame and that is not possible in this model). The SharePoint development team agreed this is not possible in the new App Part model. So, what was there response: “You can still do that in the old WebPart Model.” Thus, reiterating my point that Microsoft’s messaging is confusing. To developers they say if you can’t do it in the new model, go back to the old model. To end users they say, everything is an App.

If these Apps take off the App Store will become the defacto place to go to purchase SharePoint add-ons. Creative WebParts that need to do more than what the App part can handle might become obsolete.

Now, don’t get me wrong, I am going to embrace the App model in SharePoint 2013. I am already creating my first App that you should see on the App store soon. I just think Microsoft can do a much better job in the “Messaging” for Apps. If everything is an App, let us deploy everything through the store (even WebParts). If everything isn’t an App, be clear to the end users in how you sell your product and how you message it on your site. I guess I am use to it by now. My job as a SharePoint consultant and SharePoint Architect has always been about relaying Microsoft’s confusing messages to upper management in a clear way. I guess I have a lot of work ahead of me in that department.

SharePoint 2010 and Jquery $ sign issue

Category : SharePoint 2010, jQuery

Quick SharePoint tip of the day….

Do not use the $ shortcut in SharePoint when builidng jQuery into your site!

Example:

$(document).ready(function() {
  // Handler for .ready() called.
});

What to do instead:

jQuery(document).ready(function() {
  // Handler for .ready() called.
});

or

http://api.jquery.com/jQuery.noConflict/

Why

The $ sign in jQuery is a shortcut/shorthand to the actual object name jQuery uses (i.e.: jQuery). However, SharePoint uses this same shorthand in their Calendar WebPart. So, if you have jQuery calls on the same webpage as a Calendar, you can get conflict issues. This is an oversight (in my opinion) by Microsoft. Everyone knows that $ is reserved for jQuery. It’s just become common practice.

Anyways, I just do a find and replace  in my jQuery files to replace $ with jQuery and it fixes the issue.

SharePoint 2010 Class Registration Form

48

Category : Designer, InfoPath, SharePoint 2010

This walkthrough shows how to build an automated registration form that closes down registration if the seats in the class fill up.

I will say up front that this solution uses a lot of tricks and is somewhat advanced. But, it is a no code solution that uses InfoPath Forms, SharPoint Designer Workflows, Calculated fields and SharePoint lists.

If anyone has any suggestions for improvements to this solution, please feel free to comment.

Note: You will need SharePoint Designer 2010 and InfoPath Designer 2010 to complete this walkthrough

Create the Lists

  1. Calendar List – use the out of the box Calendar list and add these fields
    1. Seats – Number field
    2. FilledSeats – Number field
    3. RemainingSeats
      1. Calculated Field
      2. Formula: =Seats-FilledSeats
      3. Data type returned: Number
    4. SeatsIncrement
      1. Calculated Field
      2. Formula: =FilledSeats+1
      3. Data type returned: Number
    5. Closed – Yes/No
      1. Default Value: No
    6. StaticID – Number
      1. Note: This is a Hack we have to put in because we can’t use the real ID field in a calculated column. We will use a workflow to fill it in correctly later. I am open to suggestions on a better way to do this
    7. Register
      1. Calculated Field
      2. Data type returned: Single line of text
      3. Formula
        
        =IF(Closed=TRUE,"Closed for registration",IF(RemainingSeats>0,"<a href='#' onclick='OpenLandLRegistration("&StaticID&")'>Register</a>","Class is Full"))
        
  2. Attendees List – custom SharePoint list, add these fields:
    1. Username
      1. Single line of Text Field
      2. Required
    2. Meeting
      1. Lookup Field
        1. Get Information from – Calendar List created earlier
        2. In this column – Title field
    3. MeetingID – Single line of text field

Workflows

SetStaticClassID Workflow

The SetStaticClassID Workflow is really a hack because SharePoint won’t let you use the ID field in the calculated columns. All we are doing is setting a number field with the ID field every time the calendar item is created or modified. For our particular situation, this will work fine. However, don’t assume this technique will work in every situation you need to use the ID field in a calculated column.

Go to the Calendar List created earlier. Edit the Calendar List in SharePoint Designer (note: you will need SharePoint Designer 2010 to do this)
Calendar Edit

  1. Choose List Workflow in the Ribbon of SharePoint Designer
  2. Give the Workflow a good name – something like SetStaticClassID
  3. Add an Action – “Set Field in Current Item”
  4. Click the “field” link – choose StaticID
  5. Click the “value” link and clickt the fx button:
    1. Data source: Current Item
    2. Field from source: ID

Your Workflow should look like this:

StaticID Workflow

Save your work

Go back to the settings page for the Workflow. Set the Start Options for “Start Workflow automatically when an item is created” and “Start workflow automatically when an item is changed”

Save and Publish your workflow

Registration Workflow

The Registration Workflow is one of the main parts of this solution. This is the Workflow that will update the remaining seats in the calendar list when an Attendee register for the course.

Go to the Attendee List created earlier. Edit the Attendee List in SharePoint Designer.

  1. Choose List Workflow in the Ribbon of SharePoint Designer
  2. Give the Workflow a good name – something like Registration
  3. Add an Action – “Update List Item”
  4. Click the “this list” link in the action
  5. Change the list ot the Calendar list created earlier
  6. Click the “Add…” button
    1. Choose “FilledSeats”
    2. Click the fx button for the value
      1. Data source: Calendar
      2. Field from source: SeatIncrement
      3. Field: ID
      4. Value – click the fx button
        1. Data source: Current Item
        2. Field from source: Meeting
  7. In the Find the list item section
    1. Field: ID
    2. Value – click the fx button
      1. Data source: Current Item
      2. Field from source: Meeting

Save your work

Go back to the settings page for the Workflow. Set the Start Options for “Start Workflow automatically when an item is created”

Save and Publish your workflow

InfoPath Form

The end user will eventually register through the InfoPath form on the Attendees list.

  1. Go to the Attendees list in SharePoint
  2. Choose to Customize the Form in the Ribbon (note: you will need InfoPath Designer 2010 to do this)
    Customize Form ribbon Button
  3. AutoPopulate the Title Field: In the title field of the form
    1. Right-click – Text Box Properties
    2. Default value – click the fx button
    3. Add this in for the Formula:
      concat(userName(), " registration for event number ", Meeting)
      

      Note: copy and paste will not work on this formula. You will have to delete the “Meeting” string in the formula and use the “Insert Field or Group” button instead and choose the Meeting field

  4. Add a formatting rule – “Hide this control” to both the Title and MeetingID fields
    Formatting Rule
    Note: You should also delete the label for these fields and move them to the bottom of the form and delete the empty table rows they were in. This will make these fields invisible to the end user, but they will still be there to bind to the SharePoint list
  5. In the Username field of the form
    1. Right-click – Text Box Properties
    2. Default value – click the fx button
    3. Add this in for the Formula: userName()
  6. Add a formatting rule to the Username field to “Disable this control”
  7. In the Meeting field of the form
    1. Click the “Default Value” button in the Control Tools – Properties tab of the ribbon
    2. Default value – click the fx button
    3. Add this in for the Formula using the “Insert Field or Group” button: MeetingID
  8. Add a formatting rule to the Meeting field to “Disable this control”
  9. Publish the form
    Publishg

Querystring

In order to automatically set the the meeting in the InfoPath form, we will use a query string to the MeetingID field. There are a few problems to this:

  1. You can’t send querystrings to InfoPath: Solution = use a Query String Filter Web Part on the SharePoint page
  2. The Query String Filter Web Part can’t set a lookup field. Since our Meeting column is a lookup field, this won’t work. Thus, we created a MeetingID field. This is a hidden field on the InfoPath form that is purely used to set the Meeting lookup field in the form. The end user will never see this field

Go to the Attendees list on the SharePoint site

Right-Click on the “Add new item” link and choose to open in a new window or a new tab

Now you will be on the edit form page – click Site Actions – Edit Page

Add a Query String (URL) Filter field to the site

Modify the Settings and add

  • Fiter Name – QueryString
  • Query String Parameter Name – meeting_id

Connect the Query String (URL) Filter Web Part to the InfoPath Form Web PartQueryString

Use the “MeetingID” filed as the Consumer Field Name

Now when anyone comes to the new form of your Attendees list, it will be filtered by the querystring on the MeetingID field. The InfoPath form is setup to use the MeetingID text field to populate the Meeting dropdown box. This allows us to automatically pick the dropdown of the event the attendee wishes to register from.

Javascript

The last step to this is a javascript file. The javascript does two things:

  1. Creates the dialog box javascript to open our new form. The call to this javascript method is in the calculated field on the attendees list to register
  2. Turns the calculated field column into html (reference: http://sharepointjavascript.wordpress.com/2009/10/15/reformat-url-from-calculated-column-with-decent-clickable-link-text/)

Note: The solution below uses JQuery because it is the easiest way to loop through multiple elements on the client side. If you do not have JQuery in your solution then:

  1. Download the latest version of JQuery (use a “minified” version) from here: latest version of JQuery
  2. Upload the file to your SharePoint site. I usually like to use the Style Library library at the root of the site collection
  3. Add a reference to JQuery on your page:
    <script type="text/javascript" src="/Style Library/jquery-1.7.2.min.js"></script>
    

    Note: consider adding this as the first line of text in a Text File and then add the rest of the Javascript below to that same Text File. Then you can upload the Text File to a library on your site (I usually use the Style Library or Site Assets Library for this) and you can reference the text file from a Content Editor WebPart on the page we are creating.

IMPORTANT: Please change the url in the javascript to point to your new form (remember, you can right click on the add new on the Attendees list and open in new tab or window). This will show you the path to the new form and the List GUID. Also, make sure you keep the meeting_id at the end as a query string parameter.


<script type="text/javascript">
function OpenLandLRegistration(meeting_id){
     var options = {
          url:"/Lists/Attendees/Item/newifs.aspx?List=034d3042%2D1f03%2D43cc%2D96fc%2Dc4ef0acfa92a&meeting_id="  + meeting_id,
          width: 750,
          height: 600,
          dialogReturnValueCallback: DialogCallback
     };
    SP.UI.ModalDialog.showModalDialog(options);
}

function DialogCallback(dialogResult, returnValue){  }

// Reformat the url in the calculated column
reformatCalculatedColumnUrl();

function reformatCalculatedColumnUrl(){
     $(".ms-listviewtable td.ms-vb2:contains('href')").each(function(){
       $(this).html($(this).text());
     });
}

</script>

Piecing it together

All you have to do now is add the Calendar list as a webpart to the page in SharePoint you want this at. Also add a reference to the javascript on that page (Quick tip: Add the above javascript to a text file in SharePoint, put a Content Editor WebPart on your page and reference the text file in the options of the Content Editor Web Part. Just make sure this Content Editor WebPart is underneath the Calendar list webpart)

Edit the Calendar list webpart and choose the default view (this should be the All Events or Current Events view depending on yoru requirements). Do not use the Default Calendar view (so that you can show the new register link). Modify the view you chose. Make sure the “Register” column is visible to the end users because that is the link they will click to register.

RegisterListExample

Now the end users can add a new meeting in the Calendar (make sure they know to set the amount of seats available). I also suggest putting a nice message on the InfoPath form telling the end user to Save the form to register for the class. Otherwise, it might not be intuitive for the end user to know to hit the Save button in order to register. You could also add a Register button that just saves the form if you want.

Html in SharePoint 2010 WebPart Title

4

Category : SharePoint 2010

I received an interesting SharePoint design today where the WebPart titles had two colors. Ex: the place for News and Announcements

I wasn’t really sure how to accomplish this since SharePoint renders the WebPart titles as simple h3′s with spans in them. At first I thought I’d just type html into the title area. So, I decided to put this in my title: the place for <span> News and Announcements </span>. Then I used css to do my colors: I made the .ms-WPTitle light grey and the .ms-WPTitle span green. But, of course it wasn’t that easy. SharePoint actually wrote out the word “span” instead of rendering it as html: Ex: the place for <span>News and Announcements</span>

At this point I thought I was stuck. I figured I was going to have to add content editor WebParts on top of all my other WebParts just to build titles. It was going to be a pain. But, as I was looking at the underlying html that SharePoint produced, I had an idea. It looked like SharePoint was setting to the html to the actual text literal. So, what if I use javascript to re-write the exact same text? Javascript should write it as html, right?

Anyway, without further ado, here is my javascript. I used jquery (because I have it in my masterpage). I am sure it can be done with regular javascirpt, but this was easier for me.


$(function () {
    //Replace webpart header text with html version
    $('.ms-WPTitle span').each(function () {
        $(this).replaceWith($(this).text());
    });
});

With the above javascript referenced in my MasterPage, it renders any html I put into a WebPart header now. I think it is a pretty interesting trick that could be used for all different kinds of designs.

SharePoint 2010 PowerShell enable/disable feature for all site collections

1

Category : Powershell, sharepoint

A lot of enterprise portals build multiple site collections within the web application of a SharePoint farm. This is a scalable architecture that allows for separation of databases, site collection administration differentiation and a host of other benefits from the SharePoint administration point of view. This architecture also has some downsides including global navigation and different settings on the multiple site collections. If this is your architecture of choice, enabling features across all site collections is also an issue. What if you buy a third party product and need to enable the feature globally? What if you build a reusable component? Every time I need to do this I find myself Googling Binging Googling the answer to this question.

Below are helpful commands that wrap the Enable and Disable features in the get all site collections for a web application. Also, notice the “whatif” command for testing. This is a very valuable functionality of PowerShell that I highly suggest using before running the commands.

Enable Feature Testing

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Enable-SPFeature “MyFeatureID” -Url $_.Url -WhatIf}


Enable Feature without Confirmation

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Enable-SPFeature “MyFeatureID” -Url $_.Url -confirm:$false}’


Disable Feature Testing

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Disable-SPFeature “MyFeatureID” -Url $_.Url -WhatIf}


Disable Feature without Confirmation

Get-SPWebApplication “<WebApplicationURL>” | Get-SPSite -Limit ALL |
ForEach-Object {Disable-SPFeature “MyFeatureID” -Url $_.Url -confirm:$false}



Hope this helps someone else. Also, sorry for the forum I originally got this answer from. I’d give you credit if I remembered where it was. I just had this in my notes and decided to put it on my blog in case it helps others.