01 October, 2020
Synopsis: So why would you ever need to feel the pain of creating Content Types from scratch and associate Site Columns also in code with them? Well, the one glaring reason is that if you create site columns and content types out of Code, you lose the control of assigning the GUID which is in effect the id designator of the object. If you cannot control that, then as you move through a proper SDLC with a DTP environment, you in essence lose control over the same IDs [objects] being the same across the entire environment. The second reason is that you have a clean and automated way to deploy your solution to any environment; inherently you could package and sell this solution if you wanted to. Next, and very appropriately, we are doing this as a Sandbox Solution because EVERYTHING we are doing for this effort will be in the Database, nothing will be on the File System. This is where you as a developer can do all the damage you
Aspired to become a SharePoint? Explore the post to discover the know-how on the "" course.
want without worrying about the Farm Admin calling you saying “… Once you have your Sandbox Solution set, let’s had some “SharePoint Items” first will be a Content-Type As you see below, I am calling mine AdotobClient. The idea here is that for my company Adotob, LLC, I am creating a Content-Type that inherits from the Item Content Type which will hold Client-specific data. The important thing here is that as a Content-Type, this can be used all across the Enterprise in any Web by anyone. Build it once, use it many. Once named, now your project will look like this. As I mentioned before and as you will see below, everything in SharePoint inherits from a base, in this example, I am inheriting from the Item Content-Type, the wizard asks me to choose and I selected my choice Now we will do some cleanup. When you add the Content-Type, you also get an elements.xml file created for the definition of the Content-Type, now realistically if this content type is to be of any use, it will need Site Columns, but for now, we will just rename the elements.xml to something more descriptive. So, this Content-Type will have a few site columns to express what it is about the client we want to capture, it will be of many data types, text, date/time, etc. let’s go and add an Empty Element which will be the Site Columns and populate the Elements.xml with the field types. Before we do lets spot check what our Project looks like now. As for clean up, let's rename the Site Columns elements.xml to a more representative name… Lets us now flesh out the Site Columns, as you see below all the necessary information one would capture about a client. Name, address, contact info, social content, etc. Below use the Make Guide tool in Visual Studio to create those Field IDs,.
Once we do that, we now associate those site columns via the GUID [Field ID == Field Ref] in what was the elements.xml of the Content-Type Once you are done, go ahead and build and deploy your solution. Oh make sure that you have Sandbox Solution Service turned on in the Central Administration before you do that, it is not on by default. Below if you inspected your Site Settings at the top level you will find the new Content Type Trust but Verify Click inside the Content-Type, and you will find the site columns we defined. Once we have done that let's spin up a new Custom List. We will include this content type in there and create an entry To do that we need to manage content types… We select the one we created and move it over I also disabled the Item default content type what was there before so the only one that is an option is the one we created.. See below Now we will make an entry for a new client
For an in-depth understanding of SharePoint click on:
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .