This is on Tridion 2011 SP1.
I'm using the component save event in the Tridion event system to create a corresponding page and associate some metadata with that page. When specifying a schema, I am getting event logs that indicate that the UUID of the schema cannot be found.
The UUID that is in the error is the for the metadata schema I want to use, and I'm also using a local TcmUri for the metadata schema. I'm at a bit of a loss at the moment.
The .NET and resulting error are below:
Code
public static TcmUri CreatePage(TcmUri parentSgId, Component component, TcmUri componentTemplateUri, TcmUri metaDataSchemaUri = null)
{
Logging.Debug("Attempting to create page in " + parentSgId.ToString());
Page page = new Page(component.Session, parentSgId);
page.Title = component.Title;
page.FileName = component.Title;
// Add a metadata schema
if (metaDataSchemaUri != null)
{
TcmUri localMetaDataSchemaUri = TransformTcmUri(metaDataSchemaUri, parentSgId);
page.MetadataSchema = (Schema)page.Session.GetObject(localMetaDataSchemaUri);
}
// Add the CP
TcmUri localComponentUri = Helpers.TransformTcmUri(component.Id, parentSgId);
TcmUri localComponentTemplateUri = Helpers.TransformTcmUri(componentTemplateUri, parentSgId);
page.ComponentPresentations.Add(new ComponentPresentation(new Component(localComponentUri, component.Session), new ComponentTemplate(localComponentTemplateUri, component.Session)));
try
{
page.Save(true);
Logging.Debug("Created page successfully " + page.Id.ToString());
return page.Id;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
Error
Unable to find uuid:C42EE4FC-D2A2-49F5-92C7-BF6DCB014343:Metadata.
Component: Tridion.ContentManager Errorcode: 0 User: EMAKINA\MTSUser
StackTrace Information Details: at
Bair.Tridion.Events.Utilities.Helpers.CreatePage(TcmUri parentSgId,
Component component, TcmUri componentTemplateUri, TcmUri
metaDataSchemaUri) [...]