3

I'm new to Tridion and trying to update a component's metadata field from Core Service API through .Net code and got to know the following article:

https://code.google.com/p/tridion-practice/wiki/ChangeContentOrMetadata

I'm wondering how to get the Fields property/class in my project. Could you please shed some light on it?

// load the schema
var schemaFields = client.ReadSchemaFields(SCHEMA_URI, true, DEFAULT_READ_OPTIONS);

// load a component based on that schema
var component = (ComponentData)client.Read(COMPONENT_URI, DEFAULT_READ_OPTIONS);
Console.WriteLine(component.Content);

// build a magical Fields object from it
var fields = Fields.ForContentOf(schemaFields, component);

// let's first quickly list all values of all fields
foreach (var field in fields)
{
    Console.WriteLine(string.Format("{0} (Type={1})", field.Name, field.Type));
    foreach (var value in field.Values)
    {
            Console.WriteLine("\t" + value);
    }
}
  • any luck Anthony? – Raj Kumar Jul 18 '14 at 9:04
3

Download/copy source code from following class and include it in your project.

Field Class

| improve this answer | |
  • @Antony: I will suggest to Google/search SE before posting such small issues on this forum. this link was part of article you shared. – Raj Kumar Jul 18 '14 at 14:34
  • Indeed i did a round of search in Google and stack exchange before raising my question here. Anyways, i overlooked at the article. – ARRX Aug 13 '14 at 14:17
  • 1
    Worth noting that this repo has now moved and the source is now here: github.com/TridionPractice/tridion-practice/blob/master/… – Jonathan Williams Oct 15 '17 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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