0

We performed the bulk update on component using core service and we found out that rich text fields are not updated properly. There are many schema so we want to find out all the schema that contains a rich text field.

One way could be to open each schema and check however that is not the option suitable for our situation as we have many schema.

Is there any way I can perform this search through CME or Core Service or TOM.Net API?

1

May be this post is helpful for you! Copied the below code extract from the post.

 SessionAwareCoreService2010Client client = new SessionAwareCoreService2010Client();


client.ClientCredentials.Windows.ClientCredential.UserName = "myUserName"; 
client.ClientCredentials.Windows.ClientCredential.Password = "myPassword";
client.Open();
SchemaFieldsData fields = client.ReadSchemaFields("tcm-x-y-z",
                                              true, new ReadOptions());


foreach (var field in fields.Fields)
{
   if (field is field is XhtmlFieldDefinitionData)
   {
      return Constants.DataType.STRING;
   }
}
  • I was looking for some other optimized approach but that seems to be not there so accepting your answer. – Hiren Kaku May 19 '16 at 21:13
0

You could query the schemas with a simple C# Code Fragment TBB using Tom.NET with the following code:

Yoy can insert this TBB in a Template, change the uri of the root folder, and run it in TemplateBuilder.

<%@Import Namespace="Tridion.ContentManager.ContentManagement.Fields" %>

Session ses = engine.GetSession();
String strRoot = "tcm:3-1-2";

TcmUri uriRoot = new TcmUri(strRoot);
Folder folderRoot = new Folder(uriRoot, ses);
log.Debug("Root folder " + folderRoot.ToString()); 

// filter for schemas and recursive (subfolders)
 OrganizationalItemItemsFilter oiif = new OrganizationalItemItemsFilter(ses)
 {
  ItemTypes = new[] {ItemType.Schema},
  Recursive = true
 };

 foreach (RepositoryLocalObject rlo in folderRoot.GetItems(oiif))
 {
  Schema sch = new Schema(rlo.Id, ses);
  log.Debug("schema: "+sch.ToString());
  SchemaFields schFields = new SchemaFields(sch, false);
  if (schFields.Fields != null){
   foreach(ItemFieldDefinition ifd in schFields.Fields){
    //log.Debug(ifd.ToString());
    if (ifd.GetType().Name == "XhtmlFieldDefinition"){
     log.Debug("EUREKA: "+ sch.Title);
    }
   }
  }
 }
0

Finding out all the schemas and the rich text field inside them is quite easy
with core service-

var itemTypes = new List<ItemType>();
itemTypes.Add(ItemType.Schema);
OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData();
filter.ItemTypes = new[] { ItemType.Schema };
XElement list = (XElement)client.GetListXml("FolderTCM of schemas", filter);
foreach (XElement organisationItem in list.Elements())
{
var data = client.Read(organisationItem.FirstAttribute.Value,new ReadOptions());
var schemaData = new SchemaData();
schemaData = (SchemaData)data;
Console.WriteLine("Schema Title  " + schemaData.Title.ToString());
string schemaID = schemaData.Id;
SchemaFieldsData fields = client.ReadSchemaFields(schemaID,true, new ReadOptions());
foreach (var field in fields.Fields)
{
if (field is XhtmlFieldDefinitionData)
{
Console.WriteLine("Rich text field in above Schema  " +field.Name.ToString());
}
}
}

Let me know if this helps.

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.