Page 1 of 1

Site Templates

Posted: 18 Oct 2019
by Office365Guy
We are using powershell scripts to correct CSL's post template deployment, working like a charm. We were wondering if we could also correct the Related Items Controls in the same fashion. This is for CSL's and RIC's connected to lists in the same site. The controls function fine if they connect to lists on others sites.

Thanks again!!!

Re: Site Templates

Posted: 18 Oct 2019
by Office365Guy
maybe something like this, we could find each list, loop files with the correct names and update each? I have used this is the past for HTML files in the site and the forms are text files like HTML.

Start-SPAssignment -Global
$web = Get-SPWeb "http://sharepointdev:90"
$list = $web.Lists.TryGetList("Site Pages")
foreach ($file in $list.RootFolder.Files)
{
if ($list.ForceCheckout) { $file.CheckOut() }
$html = [System.Text.Encoding]::ASCII.GetString($file.OpenBinary())
$html = $html.Replace("p", "P")
$file.SaveBinary([System.Text.Encoding]::ASCII.GetBytes($html))
if ($list.ForceCheckout) { $file.CheckIn() }
}
Stop-SPAssignment -Global

Re: Site Templates

Posted: 21 Oct 2019
by mnikitina
Office365Guy,

There are no special services to work with Related Items specifically, but you should be able to work with children items/documents with regular Powershell commands.

If you need something specific, could you please provide more details.

Re: Site Templates

Posted: 21 Oct 2019
by Office365Guy
This is in reference to creating a site template and repairing the related items that connect to the same site. I found if I open the forms exported .xfds file in Notepad and replaced the few references to the site, like the "SiteRelativeUrl=", then import and save the form the Related items work within the new site. We would like to edit these files live on the SharePoint site instead of exporting, editing, importing and saving to cut time in the process. This idea came from the powershell script that is used to fix the same issue with the Cross Site Lookups.

Re: Site Templates

Posted: 22 Oct 2019
by mnikitina
Office365Guy,

To change the file you need to export it first. So you need to export .xfds file, change the required fields and import file back. And this can be done with Powershell.