3

I am creating custom lists(fields,CT,List Def and list Instance) A and B with visual studio. I have site column called "Status" i have used those column name in ListA and ListB. Suddenly i need to change ListB "Status" Field display name as StatusB, Since its site column after changing the display name will affect the listA display name too. How to resolve the issues? i need to update the field in list definition?

1 Answer 1

5

In the second content type which you may have created for the ListB specify the Inherits attribute to False for ContentType property. An then in FieldRefs section rename the Status field.

<ContentType ID="CTID"
                   Name="CTName"
                   Group="CTGroup"
                   Description="CTDescription"
                   Inherits="FALSE"
                   Version="0">
        <FieldRefs>
      <FieldRef Name="Status" ID="IDOFSTATUSColumn" DisplayName="StatusB"/>
    </FieldRefs>
    </ContentType>

For more information you can refer http://sharepointnadeem.blogspot.in/2011/06/change-default-field-names-in-child.html

Here you go. This is how you can change the display name of the field using CSOM and make it a required field:

            ClientContext clientContext = new ClientContext("http://demo2010a:90");
            List list = clientContext.Web.Lists.GetByTitle("Products");
            clientContext.Load(list);
            clientContext.ExecuteQuery();
            var fields = list.Fields;
            clientContext.Load(fields);
            clientContext.ExecuteQuery();
            var field = fields.GetByInternalNameOrTitle("Status");
            field.Required = true;
            field.Title = "StatusB";
            field.Update();
            clientContext.Load(field);
            clientContext.ExecuteQuery();
7
  • i that possible to set the required field as true with this? also i need Object model code to update this i can't update scheme directly Jan 2, 2013 at 14:00
  • You had not mentioned that you needed to do it using CSOM. Anyways, so if I understand you correctly you want to change the fields display name only in the particular list and also want to make the field as required field? Jan 2, 2013 at 14:08
  • I need to to do both Jan 2, 2013 at 14:32
  • Hey Ayyappan, please mark the question as answered if it answered your question. Jan 3, 2013 at 6:01
  • This will work only in top level site it wont work for the sub sites hope u understood.Because it is in site feature. Jan 3, 2013 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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