Mapping exisitng content type to a publishing site programatically
Hi All,
I have created a site content type manually(Publishing Content type).
I need to add this content type and populate respective columns programmatically to a publishing site.
Pls help.
Thanks in advance
Patsy
Hi,
I just wanted to check, publishing site and content type both are in same web application?
Sekar - Our life is short, so help others to grow
Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
you see a reply being an answer to the question of the thread, click "Mark As Answer
Similar Messages
-
Creating the site content type failed when publish Infopath form to Sharepoint 2013
I have an InfoPath 2013 form trying to publish it to SharePoint 2013. When I click on publishing an error message appears stating "Creating the site content type failed". I can't figure out why this
is happening, any help on this one?
Also it appears the form template is uploaded when I go to the library settings under advance. When I see the .xsn file and click on it, it opens in InfoPath but not in sp.Rettajm, could you please find any errors in ULS?
-
What are the drawbacks to adding a Site Content Type to the Document Site Column?
I have a client who has enough SharePoint knowledge to be dangerous.
They are requesting that a Column be added to all Document Libraries everywhere. We built a solution that would require a bit of work when a Site Collection is created, and it would require that we run a script to identify if there are any Libraries
that do not have this Column attached.
This client wants to know why we didn't just add this Column to the default Document Site Content Type. I don't know specifics as to why that's not a good idea, just that it's not a good idea.
Can anyone point me to a resource that identifies the reasons why this is not recommended?
Thank youI'd say there's a risk that patches or upgrades could be affected by this, or overwrite the change.
In the past I've derived a Company specific Document Content Type from the Base Document CT, and added any new company wide columns to that new CT.
w: http://www.the-north.com/sharepoint | t: @JMcAllisterCH | YouTube: http://www.youtube.com/user/JamieMcAllisterMVP -
Update content type template for existing sites in sharepoint 2010 ?
Hi,
I created one custom document library (list definition) and associated 3 content types which has docment template path (\_layouts.template1.docx). I rollout nearly 200 sites with this definition. now i want to update my document template and also i want
to change template docx to dotx.
what is the best approach to apply these changes for existing sites ?
Thanks,
Surya.
suryakumarpHi suryakumar,
As I understand, you want to update the template
for existed content type.
It can be achieved by programming. There is a
SPContentType.DocumentTemplateUrl Property, which can be used to update content type.
Here is a demo:
http://officepoint.blogspot.com/2008/06/sharepoint-relink-infopath-forms-relink.html -
I'm trying to publish my site to business catalyst, but keep getting a pop-up message and muse shuts down. The error message says "SiteFile.getCRC called with no text or binary content".
No issues before, but I made a few font changes and now I won't upload. I've updated Air and uninstalled/reinstalled Muse. Not sure what the issue or where to start.
Thanks for the help!Could you please share your .muse file with us to investigate? Please email it to [email protected] If your file is greater than 20MB you can use something like Adobe SendNow or SendThisFile or Dropbox. Please do not forget to mention the link to this forum thread in your e-mail so that we can identify the file.
-
we are on on premise environment, and we have a requirement that when people create a site or a sub site or even when they add a new document library , we want to ensure our custom content type is assigned as default content type to this library.
the question is that is there any non-full trust solution, i know we probably can do it via feature stapling, or custom site template stuff. but they are NOT considered as we want PLA complianceHi,
As I understand, you would like to asscoiate a custom content type to a library when the library is created.
With OOB option, you could try add this content type to an existing library, and save library as template. Then the library template should appear in Your Apps page, that is to say, users can directly create document library based on this template.
As I tested, new document library created based on this template contains custom content type by default.
With programatically methods, please refer to the similar threads below:
https://social.technet.microsoft.com/Forums/en-US/ec9e243b-ea4c-4a46-8780-75a3a5659164/mysite-add-content-type-to-document-library-by-default?forum=sharepointadminprevious
https://social.technet.microsoft.com/Forums/en-US/e58eb107-daa5-4a51-a139-dca2b1cf8591/set-default-content-type-for-document-libraries-on-a-custom-site-template?forum=sharepointdevelopmentprevious
Regards,Please
remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected] .
Rebecca Tu
TechNet Community Support -
Content types, Required site columns, How are they supposed to work?
Hi,
I have 2 issues:
I created a Folder level content type with many Required site columns. I was hoping that when I create a new folder the new content type screen will pop up and I must enter all the required properties (metadata) for this new folder.
Issue 1) But it didn't work that way. It just required me to enter the name of the folder and the folder was created.
Issue 2) I then went to Edit Properties to enter enter all the required metadata. I would like to have my newly created content type to be the default. So that when I open up the Edit Properties the popup screen would defalt to my new
content type. But it defaults to "Folder" Content type. even though in liberary setting, My new content type was the only one check "visible" and set as default.
Can someone please help? Am I missing something?
Thanks!I don't think you can do what you want to do using only out of the box features. A few notes:
Users will need to click the New Document dropdown in the ribbon to select your new folder content type. (I.e. Don't click New Folder)
The "default" option in the content type list is to pick the default content type to be selected when you click the New Document button. (I.e. it won't impact the New Folder ribbon button)
The ribbon button for New Folder is hard coded to use the built in folder feature.
You may want to look into the 2010 Document Set feature to create folders with metadata. It will do what your custom content type does and a lot more.
Possible solutions:
Create JavaScript hack that changes the New Folder link in the ribbon to go to the New Document link for your custom content type.
Create a Visual Studio Feature to hide the New Folder button and add a new New Folder button that points to the New Document link for your custom content type.
Leave the existing New Folder button there and create Feature to add a new custom button for your content type.
Mike Smith TechTrainingNotes.blogspot.com
my SP customization book -
How to programmatically create a site column and a content type
Hello,
I'd like to create a site column (let's say a field text) and a content type, only using c# -i.e. I don't want to add new item/column and then xml. This code will be added to a FeatureActivated.My code is :
public override void FeatureActivated(SPFeatureReceiverProperties properties) {SPWeb rootweb = (SPWeb) properties.Feature.Parent;
SPFieldText field = new SPFieldText(SPfiledscollection???, "field1");
if (field != null)
rootweb.Fields.Add(field)
rootweb.Update();
} SPContentType newContentType = new SPContentType(spcntenttypeId??, SPContentTypeCollection ??, "content1");
rootweb.ContentTypes.Add(newContentType);
rootweb.Update();
Are there any sample codes out there? I've only found samples using xml - which has an irritating "feature"
Thank you
ChristosNice code and it helped me understand. Some small questions. I'm trying to make all the "data" for a (sub)web site.
So, I think, my steps are:
1. create site columns+content type
2. create list
3. create a lookup site column that uses the list on <2>
4. create content type that uses the site column on <3>
5. Create the list for the content type on <4>
My confusion is: should I use one feature for everything? Your code is using scope=site, so i need to "hardcode" the web site's name. I don't mind doing that , I just don't know how to use scopes in features for creating data.
Thank you
Christos -
I have two different Site Asset libraries. The Site Asset Picture library has items of
content type picture. The Site Asset Image Library has items of
content type image.
1) I do not quite understand the different between a picture content type versus an image content type.
2) the thumbnail and preview columns do not display the image in the Site Asset
Image Library. (the image does display in the thumbnail column of the Site Asset Picture library.) I expected the image to display in the Site Asset Image Library the same as it does in the Site Asset Picture library.
Why doesn't it?
Betty
Betty StolwykI have subsequently found out that our "Site Asset Images" library is a Document Library to which someone must have replaced the Document content type with an Image content type. I also found out that picture previews/thumbnails cannot be displayed
in Document libraries. So the problem was the library type, not the content type.
So I simply created a new Picture Library (whose content type = picture) and copied the files into that and the thumbnails displayed just fine!
I bet what led to this is the default "Site Assets" library that is created for a new Team site. It is just a document library but sounds very similar to the "Assets" library. I can imagine someone thinking the "Site Assets" library was a standard
container for images, and simply changed the name to better identify the content!
As far as 'image' vs 'picture' content types, I noticed that a new Picture Library contains a content type of 'picture', but an Asset Library contains a content type of 'image' (as well as audio and video). Although the 'image' content type has a few
more fields than the 'picture' content type (picture content type does not have thumbnail), the actual Picture Library contains pretty much all the same fields, including the thumbnail. So for all practical purposes, either library type can be used for
storage of pictures. I am guessing that the Pictures Library which uses the picture content type is for backwards compatibility purposes, and that the 'image' content type is newer, being derived from the new "Rich Media Asset" content type and used
in the new Asset Library which can hold audio and video in addition to pictures.
Microsoft Help also mentioned that a Picture Library has a slide view which an Asset library does not. So my take on that is that if you want the potential of seeing your pictures as a slide show, put them in a Picture library which is still using
the 'picture' content type of previous SharePoint versions. If you want to keep pictures organized with audio/video files, then put them into an Asset library which uses the 'image' content type derived from the new Rich Media Asset content type.
Betty Stolwyk -
SharePoint 2013 Custom Content Type with Site Column custom validations
Hello,
Can somebody please suggest me how I can create custom content type with site columns with custom validation to site columns programmatically?
Thanks,
Praveen Kumar PadmakaranHi,
From your description, my understanding is that you want to create content type with site column with validation.
You could create a site column, and add some validation to the site column. After you could create a custom content type, please add the site column with validation to the content type. Please refer
to this code below:
static void Main(string[] args)
// replace your url
using (SPSite site = new SPSite("http://sp/sites/sp2013"))
using (SPWeb web = site.OpenWeb())
//define the type of the field
SPFieldType type = SPFieldType.Number;
// create a site column
SPField field = CreateSiteColumn(web, "newTest", type, "");
// add custom formula for the field
SPFieldNumber fieldNumber = web.Fields.GetField("newTest") as SPFieldNumber;
fieldNumber.ValidationFormula = "=[newTest]>5";
fieldNumber.ValidationMessage = ">5";
fieldNumber.Update();
SPContentTypeId parentItemCTypeId = web.ContentTypes[0].Id;
// create custom content type
SPContentType contentType = CreateSiteContentType(web, "newContent", parentItemCTypeId, "Custom Content Types");
// add the site column to the content type
AddFieldToContentType(web, contentType, field);
// add fiedl to contenttype
public static void AddFieldToContentType(SPWeb web, SPContentType contentType, SPField field)
if (contentType == null) return;
if (contentType.Fields.ContainsField(field.Title)) return;
SPFieldLink fieldLink = new SPFieldLink(field);
contentType.FieldLinks.Add(fieldLink);
contentType.Update();
// create a custom content type
public static SPContentType CreateSiteContentType(SPWeb web, string contentTypeName,SPContentTypeId parentItemCTypeId, string group)
if (web.AvailableContentTypes[contentTypeName] == null)
SPContentType itemCType = web.AvailableContentTypes[parentItemCTypeId];
SPContentType contentType =
new SPContentType(itemCType, web.ContentTypes, contentTypeName) { Group = @group };
web.ContentTypes.Add(contentType);
contentType.Update();
return contentType;
return web.ContentTypes[contentTypeName];
// create a site column
public static SPField CreateSiteColumn(SPWeb web, string displayName,SPFieldType fieldType, string groupDescriptor)
if (!web.Fields.ContainsField(displayName))
string fieldName = web.Fields.Add(displayName, fieldType, false);
SPField field = web.Fields.GetFieldByInternalName(fieldName);
field.Group = groupDescriptor;
field.Update();
return field;
return web.Fields[displayName];
You could refer to these articles:
C# code to create Site Column, Content Type, and add fields to Content Type
http://spshare.blogspot.jp/2013/10/c-code-to-create-site-column-content.html
How to do custom validation for site column in SharePoint
http://www.c-sharpcorner.com/uploadfile/anavijai/how-to-do-custom-validation-for-site-column-in-sharepoint/
Best Regards,
Vincent Han
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected]. -
Managed metadata columns in document information panel with multiple content types
Hi everyone,
The problem I have is that for custom content types not all managed metadata columns are displayed in Document Information Panel (DIP) for the document in the Office client application.
However, everything works fine with 1 specific content type. Even though the others using exactly the same site columns. The content types are deployed using visual studio to the content type hub, and after this the content types are correctly published to
the site collections, there are no publish issues here.
When I create a document based on the second content type in the same library, all fields are showed in the document information panel, except the managed metadata columns.
Detailed explanation:
Library: procedures
Content types:
- simple procedure (with 4 managed metadata fields and some other text fields)
- procedure with approval (with the same 4 managed metadata fields and some other text fields)
Scenario 1: I add the 'simple procedure' content type to the procedures library as only content type. Everything works fine, and all fields show correctly in the document information panel in Word.
Scenario 2: I add the 'procedure with approval' content type to the procedures library as only content type. Everything works fine, and all fields show correctly in the document information panel in Word.
Scenario 3: I add the 'simple procedure' and 'procedure with approval' content types to the document library procedures (added simple procedure first). When I create a new document based on the 'simple procedure'
content type, everything works fine and he shows all metadata fields. When I add a new document based on the 'procedure with approval' content type, the document information panel shows correctly, except all managed metadata fields. These are not visible at
all. Though they worked perfectly in scenario 1 and 2.
Is this a known issue or is there a workaround for this?
Thanks in advance!
Kind regards, DavyYes!
This problem is solved right now.
My issue was that I'm using custom content types deployed by Visual Studio in the content type hub. To create a managed metadata site column in visual studio, you need to have first of all your managed metadata field, but also a hidden field accompagnied
to make the actual mapping like the example below:
<Field ID="{B654D984-187A-471B-8738-F08F3356CFDA}"
Type="TaxonomyFieldType"
DisplayName="Countries"
ShowField="Term1033"
EnforceUniqueValues="FALSE"
Group="Demo"
StaticName="Countries"
Name="Countries">
<Customization>
<ArrayOfProperty>
<Property>
<Name>TextField</Name>;
<Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{67308AC2-9556-456B-BF9E-43E8F23EBEE6}</Value>
</Property>
</ArrayOfProperty>
</Customization>
</Field>
<Field Type="Note"
DisplayName="Countries_0"
StaticName="CountriesTaxHTField0"
Name="CountriesTaxHTField0"
ID="{67308AC2-9556-456B-BF9E-43E8F23EBEE6}"
ShowInViewForms="FALSE"
Required="FALSE"
Hidden="TRUE"
CanToggleHidden="TRUE"
Group="Demo"
RowOrdinal="0"
/>
</Elements>
VERY important here is that when you create your content type using visual studio, you not only have to add the managed metadata site column in your xml (which let the content type work already perfectly) but also add the hidden field to your content type
xml !! This way, SharePoint knows that when you have multiple content types with the same site columns in the same library, the second content type also need to get the hidden field from this site columns like in the example below!
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Document (0x0101) -->;
<ContentType ID="0x010100571ebc0f478a49d5a775039347ee1535"
Name="Document Location"
Group="Demo"
Description="A content type containing Managed Metadata Column."
Inherits="TRUE"
Version="0">
<FieldRefs>
<FieldRef ID="{B654D984-187A-471B-8738-F08F3356CFDA}" Name="Countries"/>
<FieldRef ID="{67308AC2-9556-456B-BF9E-43E8F23EBEE6}" Name="CountriesTaxHTField0"/>
<FieldRef ID="{f3b0adf9-c1a2-4b02-920d-943fba4b3611}" Name="TaxCatchAll"/>
<FieldRef ID="{8f6b6dd8-9357-4019-8172-966fcd502ed2}" Name="TaxCatchAllLabel"/>
</FieldRefs>
</ContentType>
</Elements>
I'm very happy I found this solution, because in the whole project i'm implementing, this was used a lot!
Special thanks to the blog of @cann0nf0dder (http://cann0nf0dder.wordpress.com/2013/04/01/creating-a-site-column-with-managed-metadata) which let me think about this!
This ticket is answered now! :-)
Kind regards,
Davy -
How to change data type of content type column.
Hi all,
I am having one content type. I have 10 columns in it. There are two rich text columns in my content type. I have attached this content type to pages library. I want to change the data type of this rich text column to "Full
HTML content with formatting and constraints for publishing".
Please assist me with this issue.
amolHi,
From your description, my understanding is that you want to change the data type for rich text column in content type.
The field type of Full HTML content with formatting and constraints for publishing is "Invalid", you could refer to this article:https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldtype.aspx.
You also could test it by create a Full HTML content with formatting and constraints for publishing column and get the its type with C# code below:
//change the URL to your SharePoint site
using (SPSite site = new SPSite("http://sp/sites/sharepoint2013"))
using (SPWeb web = site.OpenWeb())
SPFieldType type = web.Fields["Column name"].Type;
I have tested it with the PowerShell, it cannot hange the rich text column to “Full HTML content with formatting and constraints for publishing” column. If you want to edit the rich text column, you could not change the type of the column as the screenshot
below:
As a workaround, you could follow these steps to accomplish your requirement:
Create a “Full HTML content with formatting and constraints for publishing” type column in the content type.
Enter your site columns by clicking gear icon -> Site Settings -> Site columns under Web Designer Galleries under section.
Find and delete the rich text column you want to change.
Find the column you have created in step 1, and change the column’s name to the name of the text column you have deleted in step 3.
But you will lose the data of the rich text column in pages library with this method.
Best Regards,
Vincent Han
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
New Content Type with RDL template
I'm building a new Project Server 2010 site template and one of the libraries that I want to provide will store the Status Reports for each Project.
I'm struggling with what seems like a simple concept.
Create a new Content Type that uses the status_report.RDL as it's template so that users can click on the 'New Document' button drop down in the ribbon and select 'Status Report' from a list of possible document templates and then the status report opens, they
add the required parameters, run the report and then 'Export' it as an Excel Sheet which they can store in the library as a point in time report of the projects status.
Am I asking too much or do I just need to decypher the way that SharePoint builds the URL for the report from the actual .RDL file that's stored in a library in order to enter it as the location of the content type template?
Thanks in advance.
N03L.I should add that I'm planning on having this content type stored in a Content Type Hub and published for use in another Site Collection.
-
Orphaned column in a content type
Hi,
We have MMS and Content Type Hub created.
Initially we created a column and added it to a couple of content types in the Content Type Hub and published the content types.
Recently we deleted the column from one particular content type and republished the content type, but still we see the column in the content type in the subscribing site collections New and Old.
Have manually run the jobs "Content Type Hub" and "Content Type Subscriber"Hi,
According to your post, my understanding is that the content type in the subscribing site collections don’t update immediately.
I recommend that you can try to check and test the things as below:
1. Go to “SharePoint 2013 Central Administration”, click on the “Application Management”, click on the “Manage Service Application”, select “Managed Metadata Service Application”, check the Managed metadata service connection properties to make
sure that the option “Consumes content types from Content Type gallery at <your correct Content Type Hub URL>” and “Push-down Content Type Publishing updates from the Content Type Gallery to sub-sites and lists using the content type” is enabled.
2. Go to “Site Settings”, click on the “Site content types”, select the particular content type, click on the “Manage publishing for this content type”, check the “Unpublish” button and click on the “OK” button, then you need to publish it again.
3. Go to “Site Settings”, click on the “Content Type Publishing” to check the “Refresh all published content types on next update” and the “the Content Type Publishing error log”.
4. Go to “Monitoring” in the “SharePoint 2013 Central Administration”, click on the “Review job definitions”, find the
“Content Type Hub” and “Content Type Subscriber” timer jobs to run again, and check if the two timer job’s status is succeeded.
For more information, you can refer to:
http://blog.morg.nl/2011/11/content-type-hub-not-working-possible-causes/
http://social.technet.microsoft.com/Forums/sharepoint/en-US/248fcf93-5ebe-4404-8b7d-f1f32d0046e3/content-type-hub-syndication-and-publishing-works-but-not-for-already-applied-content-types?forum=sharepointgeneral
https://support.office.com/en-US/Article/Publish-a-content-type-from-a-content-publishing-hub-58081155-118d-4e7a-9cc5-d43b5dbb7d02?ui=en-US&rs=en-US&ad=US
http://sharepoint-community.net/profiles/blogs/understanding-content-type-hub-cth-in-sharepoint-2013
Best Regards,
Yumi Fu -
Get items between in the publishingstartdate and publishingend date in a content type.
Hi,
I have a content type that has two site columns publishingStartdate and publishing end date.
The content type is added to a document library.
When I create an item of the content type then it gives two options for publishing start date as immediately and then a date fiel.d
For publishing end date as never and a date control.
Now I want to be able to get only the results which are published as in todays date is in between publishing start date and end date.
But it seems publihsingstart date and publishingend date fields are text type hence I cannot run CAML Query with Greater than and less than.
Is there a way to get the items and run the caml queyHey Dennis,
Thanks for the reply.
But I am facing a strange issue. That is I also want to be able to get only those items contain certain keyword in the title column.
I am using the following query, But it is not giving the right results. Here is the query
<Where>
<And>
<Or>
<And>
<Or>
<And>
<BeginsWith>
<FieldRef Name='ContentTypeId'
/>
<Value Type='ContentTypeId'>{0}</Value>
</BeginsWith>
<IsNull>
<FieldRef Name='PublishingStartDate'
/>
</IsNull>
</And>
<Leq>
<FieldRef Name='PublishingStartDate' />
<Value Type='DateTime'>
<Today />
</Value>
</Leq>
</Or>
<IsNull>
<FieldRef Name='PublishingEndDate' />
</IsNull>
</And>
<Geq>
<FieldRef Name='PublishingEndDate' />
<Value Type='DateTime'>
<Today />
</Value>
</Geq>
</Or>
<Contains>
<FieldRef Name='Title' />
<Value Type='Text'>{1}</Value>
</Contains>
</And>
</Where><OrderBy><FieldRef Name='PostedDate' Ascending='False' /></OrderBy>
But it is giving me incorrect results.
Should I be using joins in SPQuery.
Maybe you are looking for
-
Alv Report for invoice details
Dear All, I need to develop one alv report for following details. i developed coding for this requirment but i am getting some error.kindley help me to how to move data from different internal table to final internal table. I used LOOP A
-
Item Renderer passed to legend
Hi, I have written an item renderer in Action script to change the shape of the columns on a column chart. How can I pass this through to the Legend? I tried adding: legendMarkerRenderer= "myRenderer" itemRenderer="myRenderer" inside the column serie
-
i am seeking help installing creative cloud. My browser is no longer supported it says. i have google chrome as my deffered browser. i am sorry but i am a complete amateur and not very technical savvy Thanks a mill
-
I have a few projects that I did with iMovie 09. I'm thinking of upgrading to iMovie 11. Will my projects be transferred and work well on iMovie 11 or will they not be compatible? I don't want to lose the work I have there. Thanks
-
Hi Forum, After adding items from OCI BSP application , when the catalog is displayed in SRM portal , there is one Copy icon inder Action column at item level on the portal. How to hide this? I tried by making BTN_ITMOVR_ITM_COPY BTN_ITMOVR_ROW_ADD b