none
Upgrade SharePoint Content Types / Site Columns declaratively in SharePoint hosted apps RRS feed

  • Question

  • Hi!

    I have a question where I was unable to find any official guidance for. I have created a SharePoint hosted APP where I have multiple site columns and content types (declared in XML). The APP installs and functions just fine. 

    Now I have a requirement to change a site column (Choice field, just add some more choice values). I was able to update the site column but the changes will not be reflected on the list column (I think because there no way to push the changes).

    So is there an "official" way of changing site columns?

    Any help is appreciated!
    Thx!


    Monday, March 9, 2015 11:54 AM

Answers

  • This is really not possible with a SharePoint hosted app. With a provider (azure) hosted app you can define UpdatedEventEndPoint handlers and use CSOM to push site column changes. The only possible (not recommended) way is to put logic in your app to check for the changes, and if the changes have been done then programmatically update the site columns and use the UpdateAndPushChanges method of the SPField object. But since it is a SharePoint hosted app the logic will have to execute everytime the app launches.

    Blog | SharePoint Field Notes Dev Tools | SPFastDeploy | SPRemoteAPIExplorer

    Monday, March 9, 2015 9:00 PM

All replies

  • msdn - How to: Update app web components in SharePoint 2013 :
    We do not support changing the data type of a list or content type field (column) after its initial deployment in any circumstance. In particular, do not change the data type of a field as part of an app update (not even programmatically). As an alternative, you can add a new field. If the app includes custom item create, edit, or view forms; be sure to make corresponding changes in these forms. For example, add UI for the new field and remove UI for the old one. (In a provider-hosted app, you can programmatically move data from the old field to the new one and then delete the old. )

    How to: Update apps for SharePoint


    [custom.development]

    Monday, March 9, 2015 12:28 PM
  • Thank you very much for your answer. I'm not sure you have read my question ;) I don't want to change a datatype nor do i want to add new columns (I don't even know why that's the only example in the msdn). I want to update an existing column. Scenario could also be to make a field mantatory after initial deployment.

    Thx

    Monday, March 9, 2015 1:36 PM
  • This is really not possible with a SharePoint hosted app. With a provider (azure) hosted app you can define UpdatedEventEndPoint handlers and use CSOM to push site column changes. The only possible (not recommended) way is to put logic in your app to check for the changes, and if the changes have been done then programmatically update the site columns and use the UpdateAndPushChanges method of the SPField object. But since it is a SharePoint hosted app the logic will have to execute everytime the app launches.

    Blog | SharePoint Field Notes Dev Tools | SPFastDeploy | SPRemoteAPIExplorer

    Monday, March 9, 2015 9:00 PM