I need to create a content type from my schema file which containe all my fields this is how to create a basic content type:
function Add-metaXmlFields-ToContentType($ctx, $xmlFilePath, $CT_id)
{
$web = $ctx.Web
$site = $ctx.Site
$ctx.Load($web)
$ctx.Load($site)
try
{
$ctx.executeQuery()
write-host "info: Loaded Fields and Content Types" -foregroundcolor green
}
catch{
write-host "info: $($_.Exception.Message)" -foregroundcolor red
}
$ContentType = $ctx.web.contenttypes.getbyid($CT_id)
[xml] $xmldata = [xml](Get-Content($xmlFilePath));
if (-not $xmldata)
{
return
}
Write-Host "Solutions xml file loaded successfully"
foreach ($node in $xmldata.Elements.ChildNodes) {
$field=$web.Fields.AddFieldAsXml($node.OuterXml,$true,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldInternalNameHint);
# Finally, add the custom site column to our custom content typ$fieldReferenceLink = New-Object Microsoft.SharePoint.Client.FieldLinkCreationInformation
$fieldReferenceLink = New-Object Microsoft.SharePoint.Client.FieldLinkCreationInformation
$fieldReferenceLink.Field = $field;
$ContentType.FieldLinks.Add($fieldReferenceLink)
}
# Commit changes to SharePoint
$ContentType.Update($true)
$ctx.ExecuteQuery()
}
the probleme here is :
$node.OuterXml=
<Field ID="{45FC08E4-15ED-4B99-BD0C-EAFC4C371D7A}" Name="Service Title" DisplayName="Service Title" Type="TaxonomyFieldType" Required="FALSE" Group="Custom Site Columns" xmlns="http://schema
s.microsoft.com/sharepoint/"></Field>
but :
$fieldReferenceLink.Field
AutoIndexed :
CanBeDeleted :
DefaultValue :
Description :
DescriptionResource : Microsoft.SharePoint.Client.UserResource
Direction :
EnforceUniqueValues :
EntityPropertyName :
Filterable :
FromBaseType :
Group :
Hidden :
Id :
Indexed :
InternalName :
JSLink :
ReadOnlyField :
Required :
SchemaXml :
SchemaXmlWithResourceTokens :
Scope :
Sealed :
Sortable :
StaticName :
Title :
TitleResource : Microsoft.SharePoint.Client.UserResource
FieldTypeKind :
TypeAsString :
TypeDisplayName :
TypeShortDescription :
ValidationFormula :
ValidationMessage :
Context : Microsoft.SharePoint.Client.ClientContext
Tag :
Path : Microsoft.SharePoint.Client.ObjectPathMethod
ObjectVersion :
ServerObjectIsNull :
TypedObject : Microsoft.SharePoint.Client.Field
it like no mapping there . any idea .