10

We have a particular schema in which we set a default value for a particular metadata text field. The default value gets populated if we create relevant component on tridion CME. But we want it populated through some of our applications, which basically create these components through TDSE.

I agree we can go ahead and add this one field entry in all our applications. But why does this default value is not getting populated?

  • Are you using Interop dll's in 2009? – Siva Charan May 29 '13 at 12:33
  • With CoreService, calling GetDefaultData() would get you those values, I don't know if TDSE/2009 does it. I think the default values are populated by the interface, not the core. Your app would have to read the schema and get default values for the fields that define it (like the CME does). – Nuno Linhares May 29 '13 at 12:49
10

Through TDSE, you will not able to populate the default value automatically, however, you can try the Code Block below to retrieve the default value of a particular metadata field in the Schema:

TDSEClass tdse = new TDSEClass();
tdse.Impersonate(userName);
Schema schema = (tdse.GetObject(schemaId, EnumOpenMode.OpenModeView, null,
                 XMLReadFilter.XMLReadNull) as Schema); 

TridionWebSchemaFields metadataFields = schema.MetadataFields;

var defaultValue = metadataFields.Item("[xml field name]").DefaultValue();

//OR: var defaultValue = metadataFields.Item([index]).DefaultValue(); // [index] is 1 based

I hope it helps.

  • Hey Pankaj, thanks for the answer. As per the need of our requirement we are making this value gets populated through event system for now (we basically have some save events associated with the same schema). Your answer will help us in tweaking existing applications in future. – Nageswara Sarma Aravelli Jun 4 '13 at 7:58
  • It is always my pleasure to help the community :) – Pankaj Gaur Jun 4 '13 at 8:19
2

Setting the default value for newly created components is done by the WebGUI and not by the underlying BL layers; hence creating components outside of the WebGUI will not populate default values.

If you create a component programmatically you can also programmatically set it's fields to any value of your choosing (including many more complex setups than what the default value offers; like filling multivalue fields, or component link fields, etc).

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.