<CharlieDigital /> Programming, Politics, and uhh…pineapples

24Oct/12Off

Avoid West Elm

Posted by Charles Chen

It's hard to imagine how some e-tailers are still functioning like it's 1999 in the age of Overstock and Amazon.

I ordered an item from West Elm online on October 18th assuming that I'd have it in my possession within a week.

Nope!  A week later, and nary an email on the status of the order, which is still listed as "shipping soon" on their website.

Turns out on 11/09, I'll get a call to set up a delivery date....

I don't even get the privilege of setting up a delivery date until almost a full month later?  Are master craftsmen hand-crafting my headboard, right at this very moment?  Given the reviews of their quality (or lack thereof), I think not.

I'm not sure if their stock management system sucks or what but this seems pretty crazy (OK, I'm spoiled by Prime as well).  I think it's a bit silly that I had to contact a live person to get a status on my delivery.

Turns out that this is SOP for West Elm and would have avoided them from the start had I known.

Filed under: Rants No Comments
10Oct/12Off

SharePoint DirectoryNotFoundException (0×80070003)

Posted by Charles Chen

I've been dealing with an interesting SharePoint error for the better part of a day-and-a-half now and I thought it was worth sharing.

The error surfaced was a DirectoryNotFoundException (0x80070003) when attempting to call BreakRoleInheritance in an asynchronous event receiver.

The purpose of the receiver was to read a set of rules which specified how to configure permissions for objects based on metadata and content type. However, this would fail with the aforementioned error, but only for folders.

Of course, this was a weird error because I could certainly see the folder in the list.

It turns out that the root cause is how we were setting the titles/names on our folders.  One issue with folders is that depending on how you add the list item, you may have to go back and rename it.  Otherwise, it gets a title based on its ID.

Our original logic looked like this (note the use of the Name property) and it was raised after the item was created in the list:

if (entity.ContentTypeId.StartsWith("0x0120")) // Only for folders
{
    item = list.GetItemById(item.ID);
    item["Name"] = entity.Title;
    item.SystemUpdate(false);
}

(Assume that entity is simply a container that describes the list item to create.)

The exception occurs in the case where the rename executes before the asynchronous event receiver finishes executing, thus the directory -- as originally named -- no longer exists since it's been renamed by the code above.  This caused random errors on our systems based on the order of execution and of course, when the debugger is attached, it works perfectly fine (I think because it changes the threading model).

We've changed our code now to something like this instead:

private SPListItem AddItem<T>(T entity, SPList list, string parentFileRef) where T : CtmoModelBase, new()
{
    if (string.IsNullOrEmpty(parentFileRef)) //Add to sub-folders
    {
        parentFileRef = list.RootFolder.Url;
    }

    _log.DebugFormat("Saving object to container URL: {0}", parentFileRef);

    try
    {
        Web.AllowUnsafeUpdates = true;

        if (entity.ContentTypeId.StartsWith("0x0120"))
        {
            // Add a folder (same in all cases)
            return list.AddItem(parentFileRef, SPFileSystemObjectType.Folder, entity.Title);
        }

        if (list.BaseType == SPBaseType.DocumentLibrary)
        {
            // Add a file to a document library.
            SPFolder parentFolder = Web.GetFolder(parentFileRef);

            return parentFolder.Files.Add(entity.Title, entity.BinaryContents, true).Item;
        }
        else
        {
            // Add a list item to a custom list.
            return list.AddItem(parentFileRef, SPFileSystemObjectType.File, entity.Title);
        }
    }
    finally
    {
        Web.AllowUnsafeUpdates = false;
    }
}

Which has solved the issue as the name of folder and items created from folder based content types no longer need to be updated to set the display name.

Filed under: SharePoint No Comments
1Oct/12Off

The Pineapple Lives!

Posted by Charles Chen

I had always been under the impression that the pineapple plant itself dies after it bears fruit so after my pineapple bore fruit this summer, I pretty much ignored it -- rarely watering it at all.  I've even left it out at night in sub-60F evening weather thinking that I was going to dump it anyways.

Lo and behold, as I was walking past it yesterday, I noticed something...interesting:

Pineapple with two (three??) plants

Pineapple with two (three??) plants

I'm not quite sure what happened here as it appears as if there are now three plants in my pot with two of them growing out of the original (click the picture to see a larger one).  I also peeled back the dead leaves at the base.  Check out the root system:

Check out that root system.

For reference, here is a wider shot that shows the two new (?) plants, the original plant, and the root system:

Wide shot

The pineapple is indeed a fascinating plant!

25Sep/12Off

Obama’s Address to the UN Assembly

Posted by Charles Chen

A great speech; too much to quote:

It is time to marginalize those who, even when not directly resorting to violence, use hatred of America or the West or Israel as the central organizing principle of politics, for that only gives cover and sometimes makes an excuse for those who do resort to violence. That brand of politics, one that pits East against West and South against North, Muslims against Christians and Hindu and Jews, can't deliver on the promise of freedom.

To the youth, it offers only false hope. Burning an American flag does nothing to provide a child an education. Smashing apart a restaurant does not fill an empty stomach. Attacking an embassy won't create a single job. That brand of politics only makes it harder to achieve what we must do together, educating our children and creating the opportunities that they deserve, protecting human rights and extending democracy's promise.

...when you strip all away, people everywhere long for the freedom to determine their destiny; the dignity that comes with work; the comfort that comes with faith; and the justice that exists when governments serve their people and not the other way around.

The United States of America will always stand up for these aspirations for our own people and for people all across the world. That was our founding purpose. That is what our history shows. That is what Chris Stevens worked for throughout his life.

Filed under: Awesome, News No Comments
16Aug/12Off

SharePoint ListData.svc 500 Error

Posted by Charles Chen

If you're fighting with the SharePoint ListData.svc with an odd error:

An error occurred while processing this request.

And you are using an OData operator like endswith, you may encounter this error and be puzzled with why it works for some fields but not others.

Tried various theories -- indexed column?  use the column in a view?  maybe error with the column? -- with no love until Rob thought that it might have to do with empty values.

Turns out that the underlying implementation of ListData.svc doesn't quite like it if you have un-set or "null" values in your text fields.  So a query like this:

http://collab.dev.com/_vti_bin/ListData.svc/Test?$filter=endswith(PrimaryFaxNumber, '6481099') eq true

Will fail if there is an item in the list with an empty value for PrimaryFaxNumber.

However, using a nullity check will fix the issue:

http://collab.dev.com/_vti_bin/ListData.svc/Test?$filter=PrimaryFaxNumber ne null and endswith(PrimaryFaxNumber, '6481099') eq true
Filed under: .Net, SharePoint No Comments
2Aug/12Off

Oh, Visio, How You Rustle My Jimmies!

Posted by Charles Chen

I have been working on putting together an information architecture/file plan document which shows the layout of artifacts in our SharePoint environment and came across this nice little gem after spending a bit of time putting together my stencils:

As you can see, this is the multi-connector and it seems to work great.  But then I realized that it seems that the multi-connector only allows for 6 branches...

Amusing and frustrating because it makes no logical sense to me.

Filed under: Rants No Comments
14Jun/12Off

Working With Folder Specific Views in SharePoint Lists

Posted by Charles Chen

One neat feature in SharePoint that I recently discovered is the ability to specify views specific to folder based content types in a list.

What's great about this is that if you're building a hierarchical store in a list with folder based content types, then you can have each level of the hierarchy display different views.

As an example, consider a school district.

They may map their classes like this:

  • School A (Folder based CT)
    • Grade A1 (Folder Based CT)
      • Class A1.1 (Folder Based CT)
        • Student A1.1.1 (Item Based CT)
        • Student A1.1.2
      • Class A1.2
    • Grade A2
  • School B
    • Grade B1
    • Grade B2

Now for each of the folder based content types, you can specify a view specific to that content type by using the DefaultViewForContentType="TRUE" and ContentTypeID attributes of View.  For example, on the Grade level view, when a user selects a Grade, I would want to show a column called "Teacher" because in this view, I'm showing Class items.  However, at the School level, "Teacher" doesn't make sense as a column.

Now none of this is all very difficult to figure out, however there are a few notes:

  1. To get this to work, you have to specify these values for EVERY view.  If you don't, you will see that at each level of the hierarchy, you will have the view available, but the navigation will not automatically select that content type specific view.
  2. For the default view, you need to add it as 0x012001.

This is a great tip as it creates for a much better end-user experience by allowing them to have contextual views based on the current content type.

Filed under: SharePoint No Comments
13Jun/12Off

Interviewing for SharePoint

Posted by Charles Chen

Yet another post on interviewing :)

As both an interviewer (mostly) and an interviewee on topics of SharePoint, I've been working on refining my questions and technique here to get right to the core of understanding a candidate's suitability.

As a general rule, I never start with "factoid" type questions and almost never bring them into an interview in the first place.  I don't believe in quizzing on facts unless there is a very good reason since nowadays, unknown facts can be googled instantly anyways.  Oddly enough, I only end up on factoids when I'm interviewing a very strong candidate.  I generally run interviews with a "choose your own adventure" type of style -- no two candidates ever get the same exact questions.  It works for me because I like to talk about technology and design in general.

That said, I've pretty much boiled it down to a very small set of questions that I start with to determine a candidate's level of expertise and suitability for a given role.


What do you think are some of the more interesting/significant/useful features in SharePoint 2010 compared to SharePoint 2007?

This is an open ended question and what it measures is a candidate's suitability for an architect or lead type role.  The function of an architect or lead is to understand the platform and tool as a whole so thus they need to know what they can do with the tool and understand how to compose the components and capabilities into a set of solution patterns.

With this one question, you can pretty much weed out anyone who is not suitable for an architect or a lead.  A good answer will run down a list of the core feature changes in 2010 compared to 2007 and a strong candidate will be able to identify 2-3 which she thinks are significant in her view.  

The exact ones don't matter as it's a matter of opinion, but a strong candidate will be able to talk about it with detail.  I will note that the ones that a candidate picks will help expose their strengths and leanings (enterprise content management, custom development, configuration, etc).

This question alone can carry you for 20-30 minutes of discussion.

Consider a scenario where you are developing a product that integrates with SharePoint and has a number of ASPX pages.  You would like to implement a license check on every page to ensure compliance and show an error message if the license is invalid or not found.  Give a high level design of how you would implement this.

Again, there are multiple ways to implement this but some ways are clearly better than others.  What I'm looking for here is for the candidate to expose how she thinks about SharePoint as a platform.The first sub-question is where would she propose the license be stored?  It can be stored in SharePoint itself, in the web.config, in the hive, as a persisted object, etc. -- but it is up to the candidate to justify and explain their choice.  Whatever they choose, I point out a weakness and see how they respond :)  Strong candidates can defend their position or can see the weakness and will propose a workaround.  Weak candidates get thrown off pretty easily.

The second sub-question is how the candidate would get the functionality on every page.  The best and most straightforward answer is to create a base page which implements the license check and all pages inherit from the base page and automatically get the license check capability.  There are other ways (perhaps an HttpModule?), but the point here is to see if they naturally think of inheritance to coalesce common functionality.  It's really an inheritance question put into the context of a realistic scenario -- if you understand the goal, then you can create variations of this question that suit your use cases.

Consider a scenario where you develop a component and it requires modifications to the web.config file to work (i.e. custom HttpModule, custom HttpHandler, third party library).  Can you propose a way to manage this at deployment time?

Again, a question with a lot of possible answers, but really only two optimal ones (SharePoint itself offers at least two ways of doing this and automatically propagating those changes across all servers in the farm).  The key here is that most answers will be "I'd update it manually" but this is clearly a sub-optimal solution as a farm may have multiple servers in it and each will have to be updated.  But I like this question because it's a "thinking" question, even if they don't know the answer from the framework perspective, you can tell if they are thinking about the question because some will realize that this is not manageable with a large farm and prone to errors (say 8 servers).


Of course, there are other more specific technical questions that I ask that are feature and role specific, but these three are really my "go to" questions.  What do you think?  Any other questions that you've found to be useful in interviewing for SharePoint candidates?

28May/12Off

Leadership is…

Posted by Charles Chen

Really liked this quote by Frederick Smith of FedEx from a CNNMoney article on 10 Fortune 500 Military CEOs:

"Leadership is simply the ability of an individual to coalesce the efforts of other individuals toward achieving common goals. It boils down to looking after your people and ensuring that, from top to bottom, everyone feels part of the team."

Concise and accurate.

Filed under: QOTD No Comments
10May/12Off

BarackObama.com View Source

Posted by Charles Chen

Brilliant!

Filed under: Awesome No Comments