Last active
June 5, 2018 14:29
-
-
Save justsayantan/eb3f95320f5b4792a3f51619e23cea5f to your computer and use it in GitHub Desktop.
Create Bundle Using Tridion Coreservice [C# version]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-TridionBundle | |
{ | |
<# | |
.Synopsis | |
Creates a new bundle based on specified bundle schema. | |
.Inputs | |
None. | |
.Outputs | |
Returns the newly created bundle. | |
#> | |
[CmdletBinding()] | |
Param | |
( | |
# The title of the new bundle | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$Title, | |
# The descrition of the new bundle | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$Description, | |
# The item type of the new bundle | |
[Parameter(Mandatory=$true)] | |
[string]$BundleSchemaId, | |
# ID of the parent folder. | |
[Parameter(Mandatory=$true)] | |
[string]$Parent | |
) | |
Begin | |
{ | |
$client = Get-TridionCoreServiceClient -Verbose:($PSBoundParameters['Verbose'] -eq $true); | |
} | |
Process | |
{ | |
$virtualFolderTypeSchema = $client.GetVirtualFolderTypeSchema("http://www.sdltridion.com/ContentManager/Bundle"); | |
$bundle = _GetDefaultData $client 8192 $Parent $Title; | |
$bundle.Description = $Description; | |
$bundle.MetadataSchema.IdRef= $BundleSchemaId; | |
$bundle.TypeSchema.IdRef = $virtualFolderTypeSchema.Id; | |
$bundle.LocationInfo.OrganizationalItem.IdRef = $Parent; | |
$bundle.Configuration = '<Bundle xmlns="http://www.sdltridion.com/ContentManager/Bundle"><Items/></Bundle>'; | |
$result = _SaveItem $client $bundle $true; | |
return $result; | |
} | |
End | |
{ | |
Close-TridionCoreServiceClient $client; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public VirtualFolderData CreateBundle() | |
{ | |
SchemaData bundleSchema = (SchemaData) _CoreServiceClient.Read("tcm:1-78-8", _ReadOption); | |
SchemaData virtualFolderTypeSchema = | |
_CoreServiceClient.GetVirtualFolderTypeSchema(@"http://www.sdltridion.com/ContentManager/Bundle"); | |
TcmUri folderId = new TcmUri(100, ItemType.Folder, 1); | |
VirtualFolderData bundle = new VirtualFolderData() | |
{ | |
Id = "tcm:0-0-0", | |
Title = "Test Bundle Title", | |
Description = "Test Bundle Description", | |
MetadataSchema = new LinkToSchemaData() | |
{ | |
IdRef = bundleSchema.Id | |
}, | |
TypeSchema = new LinkToSchemaData() | |
{ | |
IdRef = virtualFolderTypeSchema.Id | |
}, | |
LocationInfo = new LocationInfo() | |
{ | |
OrganizationalItem = new LinkToOrganizationalItemData() | |
{ | |
IdRef = folderId | |
} | |
} | |
}; | |
bundle = (VirtualFolderData) _CoreServiceClient.Create(bundle, _ReadOption); | |
return bundle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the scripts to create bundle/bundles through PowerShell coreservice module. Though I have mentioned about the PowerShell module, but I considered to keep C# version as well, so that anyone can pick as per their preference –
To create the Bundle I have used below Parameters –
Here is an example to create a no. of Bundles at the same time –
// Here I am creating a new folder to store all the bundles at the same place