SUMMARY
Whilst creating and populating a Bundle using PowerShell - I'd also like to assign a specific Bundle Schema to the Bundle so that I am able to then start the workflow process associated with it...
$bundleWFlowSchemaId = "tcm:99-36586-8";
$bundle.MetadataSchema = new-object LinkToSchemaData;
$bundle.MetadataSchema.IdRef = $bundleWFlowSchema.Id
this seems to be trying to attach the correct schema given it refers to it (xxxschema) in the error but I'm not certain I'm adding this to the right object?
> Exception calling "Create" with "2" argument(s): "Unable to find
> http://contentbloom.net/tridion/schemas/workflow/xxxschema:Metadata."
> At line:21 char:5
> + $core.Create($bundle, $defaultReadOptions);
> + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
> + FullyQualifiedErrorId : FaultException`1
BACKGROUND
Extending from my question on Error in Virtual Folder Type creating Bundle in PowerShell I'd like to know know how to add a specific Workflow Bundle Schema the Bundle (the next step will be to start' the respective process to finish).
Attempt 1
Taking the following that will successfully create (and populate if <items>
are added into $bundle.Configuration
) a Bundle.
$bundleFolderData = new-object VirtualFolderData
$location="tcm:aa-bb-2";
$bundle = $core.GetDefaultData([ItemType]::VirtualFolder, $location, $defaultReadOptions);
$bundle.Configuration = "<Bundle xmlns=""http://www.sdltridion.com/ContentManager/Bundle""><Items /></Bundle>"
$bundleSchemaId = $schema.Id
$bundle.TypeSchema.IdRef = $bundleSchemaId
$core.Create($bundle, $defaultReadOptions)
And seeing the c# as something along the lines of:
var bundleSchema = (SchemaData)svc.Session.Read(schemaUriOrWebdav, new ReadOptions());
var bundleSchemaUri = new Tcm.TcmUri(bundleSchema.Id);
var publicationUri = new Tcm.TcmUri(contextPublicationUri);
if (bundleSchemaUri.PublicationId != publicationUri.ItemId) {
var contextSchemaUri = GetBluePrintItemTcmId(bundleSchemaUri, contextPublicationUri);
bundleSchema = (SchemaData)svc.Session.Read(contextSchemaUri, new ReadOptions()); ;
}
I can use
MetadataSchema = new LinkToSchemaData()
{
IdRef = bundleSchema.Id
}
And then add this to the bundle metadata. [1]
So ... let's PowerShell this up, I hoped:
$bundleWFlowSchemaId = "tcm:x-x-8";
$bundleWFlowSchema = $core.Read ($bundleWFlowSchemaId, $defaultReadOptions)
$bundle.Metadata = $bundleWFlowSchema
But, this gives the error:
Exception calling "Create" with "2" argument(s): "The formatter threw an exception while trying to deserialize the message: There was an error while trying to
deserialize parameter http://www.sdltridion.com/ContentManager/CoreService/2013:data. The InnerException message was 'There was an error deserializing the object
of type Tridion.ContentManager.Data.IdentifiableObjectData. Data at the root level is invalid. Line 1, position 1.'. Please see InnerException for more details."
At line:21 char:5
+ $core.Create($bundle, $defaultReadOptions);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FaultException
Attempt 2
Well really this wasn't just my second attempt but I've missed out the annoying and the embarrassing
I thought it was odd getting a serialization error - something I've seen a lot of before when dealing with metadata.
Then it occurred that it's not metadata I'm updating here - it's the Bundle Workflow Schema so I reviewed the code and realised that the MetadataSchema and Metadata are NOT the same thing (kinda obvious on reflection!)
$bundleWFlowSchemaId = "tcm:$locationId-36586-8";
#$bundleWFlowSchema = $core.Read($bundleWFlowSchemaId, $defaultReadOptions)
$bundle.MetadataSchema = new-object LinkToSchemaData;
$bundle.MetadataSchema.IdRef = $bundleWFlowSchema.Id
now this seems to be trying to attach the schema given it refers to it (xxxschema) in the error:
Exception calling "Create" with "2" argument(s): "Unable to find http://contentbloom.net/tridion/schemas/workflow/xxxschema:Metadata."
At line:21 char:5
+ $core.Create($bundle, $defaultReadOptions);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FaultException`1
I thought it was odd getting a serialization error - something I've seen a lot of before when dealing with metadata.
Then it occurred that it's not metadata I'm updating here - it's the Bundle Workflow Schema so I reviewed the code and realised that the MetadataSchema and Metadata are NOT the same thing (kinda obvious on reflection!)
$bundleWFlowSchemaId = "tcm:$locationId-36586-8";
#$bundleWFlowSchema = $core.Read($bundleWFlowSchemaId, $defaultReadOptions)
$bundle.MetadataSchema = new-object LinkToSchemaData;
$bundle.MetadataSchema.IdRef = $bundleWFlowSchema.Id
now this seems to be trying to attach the schema given it refers to it (xxxschema) in the error:
Exception calling "Create" with "2" argument(s): "Unable to find http://contentbloom.net/tridion/schemas/workflow/xxxschema:Metadata."
At line:21 char:5
+ $core.Create($bundle, $defaultReadOptions);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FaultException`1