jan-h
9/20/2017 - 2:39 PM

Use the SDL Web Core Service to change the root element name of an embedded schema field

Use the SDL Web Core Service to change the root element name of an embedded schema field

$ErrorActionPreference = "Stop"

# get a Core Service client
Import-Module Tridion-CoreService -Verbose:$false
Set-TridionCoreServiceSettings -Version "Web-8.1" -HostName localhost -ConnectionType Basic

$client = Get-TridionCoreServiceClient                              

# get the schema to edit
$schemaId = "tcm:21-4247-8"

$schema = Get-TridionItem $schemaId
$schema.Id

# change the InterestArea embedded component root element name
$schema.Xsd = $schema.Xsd.Replace('type="InterestArea"', 'type="InterestAreaLabel"')
$schema.Xsd

# save the schema
$readBackOptions = New-Object Tridion.ContentManager.CoreService.Client.ReadOptions
$client.Update($schema, $readBackOptions)