Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

I want to create a schema with a list field by using core service so I can select the keyword when I create a component. for this I create a "SingleLineTextFieldDefinitionData" type field but I did not find any method in SingleLineTextFieldDefinitionData class for the property of Values will be Selected from a List .

how I do this so I can select the category from the list and classify the component

share|improve this question
1  
I'm wondering, are you only using Visual Studio intellisense to see what is available? If so I can recommend downloading the SDL Tridion 2013 SP1 Core Service API reference guide (.chm file) from the documentation. That gives a much better overview of what members are available for a given class. –  Bart Koopman May 14 at 9:08
add comment

3 Answers 3

up vote 4 down vote accepted

You need to use singleLineTextFieldDefinitionData.List to have list type field

SingleLineTextFieldDefinitionData singleLineTextFieldDefinitionData = new SingleLineTextFieldDefinitionData();
singleLineTextFieldDefinitionData.Name = "OptionField";
singleLineTextFieldDefinitionData.Description = "Option Field";
singleLineTextFieldDefinitionData.List = new SingleLineTextListDefinitionData()
{
    Entries = new String[] { "Yes", "No" }
};

Especially to target keyword related schema field with list type,

KeywordFieldDefinitionData keywordFieldDefinitionData = new KeywordFieldDefinitionData()
{
    Name = "MyList",
    Description = "It's My List",
    Category = new LinkToCategoryData()
    {
        IdRef = "Category-TCM-ID"
    },
    List = new ListDefinitionData()
    {
        Type = ListType.Tree
    }
};
share|improve this answer
    
thanks one more things I want to ask that in tridion gui when we checked the Values will be Selected from a List: property a category check box appear automatically and when we select the category checkbox our category are display in list how I do this using core service after list type field create –  pankaj Sharma May 14 at 9:14
    
@pankajSharma: Updated with more detailed example related to keyword. –  Siva Charan May 14 at 9:35
1  
Check the schema source after you do it in the UI - this should give you enough pointers to "reverse-engineer" it. At least, that's what I would do. –  Nuno Linhares May 14 at 9:35
    
@NunoLinhares: Yeah that's a great point. –  Siva Charan May 14 at 9:37
add comment

You should set SingleLineTextFieldDefinitionData.List property

share|improve this answer
add comment

For a text based option list you can use the SingleLineTextFieldDefinitionData.List property as explained in the given answers by @user978511 and @Siva.

If you want to populate the values in the list with Keywords from a Category, you will have to use the KeywordFieldDefinitionData class instead for your field. While in the SDL Tridion UI, it is initially shown as a Text field, this is underwater a Keyword field once you select a Category for the list.

The KeywordFieldDefinitionData.Category property is where you will be able to set the Category from which you need the Keywords. The KeywordFieldDefinitionData.List property should be automatically populated from that point onwards.

share|improve this answer
add comment

Your Answer

 
discard

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.