another technical blog...technically

Monday, April 9, 2018

Update Content Type in sandbox solution: a forgotten beauty

Like i said in previuos blog posts, i'm using a lot BP with SP on premise or O365, in order to implement a centralized approach to attended RPA.
As we already know, nowaday the most used approach is to use PnP scripts and this is something i really like, but i also have to deal with a great team with really good skills in RPA and IT in general, but i could not waste my time explaining how to use another tool, because of we need to just to set up some SP web sites with old-fashioned custom lists.
So i explained them something about sandbox solution, but surprise surprise, customer enjoyed a lot the POC and asked us lot of CRs, including adding some JavaScript to the custom form and (nooooo!) adding fields to content types.
With Francesco Cruciani (thx man), I figured out how to solve the problem, simply attacking the feature manifest.
The solution is really simple and you can download it simply clicking here.
As you can see we have:
  • Some fields
  • 1 CT
  • 1 List definition
  • 1 Feature 
Solution structure
Installing the sandbox you will just have to provision manually the list instance in order to be ready to use it.
Now, let's start with the update:
  1. Let's add a Field file: we called it Fields_Update
  2. Then update the CT and List Definition: we like order ;-)
The key is now simply here:
Only visible difference is Fields_Update
We just add the new module in the feature
Now let's focus on Test.SandBox.DataStructure.Template.xml

  
    
      
        
      
      
    
  

As you can see we have just applied the new manifest, with an explicit reference to the action of adding field to a content type and then pushing down the update, so also the content type instances will be updated: you just have to upload again the wsp with a different name, and upgrade the solution from SandBox solution menu and that's all.

No way if you want to change order of Field in the mask or change data type, we have not investigated further.
This post helps you only to remember that sometimes, old fashioned way could be useful to make your life a little easier.
written in: Milano MI, Italia

1 comment:

Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?