SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add a new column to a contentytpe and type note but with rich text enabled.

It doesnt throw any exceptions: In the site columns definition it appears as Multiple lines of text with rich text enabled.

However when I place the cursor inside the field, the ribbon is not chaning to show the bold,italic, etc.

the code is as follows:

using (SPSite spsite = new SPSite(strurl))
                    using (SPWeb currentWeb = spsite.OpenWeb())
                            currentWeb.AllowUnsafeUpdates = true;
                            SPContentType agendaPointsProposedCT = currentWeb.ContentTypes[Meetings.Common.Constants.CONTENTTYPES_AGENDAPOINTPROPOSED_NAME];
                            string reasonReturnedFieldName = currentWeb.Fields.Add(Meetings.Common.Constants.FIELDS_AGENDAPOINTSREASONRETURNED_NAME, SPFieldType.Note, false);
                            SPFieldMultiLineText reasonReturnedField = currentWeb.Fields.GetFieldByInternalName(reasonReturnedFieldName) as SPFieldMultiLineText;

                            reasonReturnedField.Group = "$Resources:XXX,Field_XXXColumns_Group";
                            string schemaXmlWithResourceTokens = reasonReturnedField.SchemaXmlWithResourceTokens;
                            string displaynamelocalized = "$Resources:XXX,Field_ReasonReturned_Name";
                            string returnValue;
                            int indexOfAttributeName = schemaXmlWithResourceTokens.IndexOf("DisplayName", StringComparison.InvariantCultureIgnoreCase);
                            int indexOfAttibuteValueBegin = schemaXmlWithResourceTokens.IndexOf('"', indexOfAttributeName);
                            int indexOfAttributeValueEnd = schemaXmlWithResourceTokens.IndexOf('"', indexOfAttibuteValueBegin + 1);
                            returnValue = schemaXmlWithResourceTokens.Substring(0, indexOfAttibuteValueBegin + 1) + displaynamelocalized + schemaXmlWithResourceTokens.Substring(indexOfAttributeValueEnd);
                            reasonReturnedField.SchemaXml = returnValue;
                            reasonReturnedField.RichText = true;
                            reasonReturnedField.RichTextMode = SPRichTextMode.FullHtml;
                            reasonReturnedField.AllowHyperlink = true;

                            agendaPointsProposedCT.AddFieldRefFromContentType(currentWeb, reasonReturnedField, true);
                            MoveFieldInColumnOrderToLastPosition(currentWeb, Meetings.Common.Constants.CONTENTTYPES_AGENDAPOINTPROPOSED_NAME, reasonReturnedField.InternalName);

  public static void AddFieldRefFromContentType(this SPContentType contentType, SPWeb web,SPField field, bool pushChanges)
            SPFieldLink fieldLink = new SPFieldLink(web.AvailableFields.GetField(field.InternalName));
            //Check if the Field reference exists
            if (!contentType.Fields.ContainsField(field.Title))
                //Do Nothing
share|improve this question
I found this,…, but I am getting the field after adding it, so no sure how to implement the solution here – Esteban V Sep 14 '12 at 14:45
I'd be curious to see what the line:contentType.Fields.ContainsField(field.Title)) returns. – Derek Gusoff Sep 14 '12 at 17:32
...because if it returns false your update code never gets hit – Derek Gusoff Sep 14 '12 at 17:34
it gets hit, the field is in the list. – Esteban V Sep 14 '12 at 18:52
up vote 0 down vote accepted

Finally, I was able to solve it:

Solution I found is here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.