Form Designer provision
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear dat,
So, the list is found, the error might be coming when you update the property bag of the site...
It's most like this line:
That needs to be changed to:
Try it like this, please.
So, the list is found, the error might be coming when you update the property bag of the site...
It's most like this line:
Code: Select all
$formProperty = "fd_MyTest_New"
Code: Select all
$formProperty = "fd_"+$ControlInventorylistTitle +"_MyTest_New"
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Dat,
Okay, the error is weird, but it does say that the form has been published. Is it true? Is the form available in SharePoint?
Okay, the error is weird, but it does say that the form has been published. Is it true? Is the form available in SharePoint?
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear dat,
One small change, please, try the following:
One small change, please, try the following:
Code: Select all
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
function GetListByInternalName($listName)
{
$rootWeb.Lists | ForEach-Object { if($_.RootFolder.Name -eq $listName) { return $_ }}
}
Try
{
$sourceUrl = "http://dsps16/sites/Test" #Read-Host "Site Collection URL"
$rootWeb = Get-SPWeb $sourceUrl
$serviceUrl = $sourceUrl + "/_vti_bin/FormsDesigner/FDService.svc"
$srv = New-WebServiceProxy -Uri $serviceUrl -UseDefaultCredential -Namespace "FormsDesigner.Data"
$srv.url = $serviceUrl
$groupID = [Guid]"00000000-0000-0000-0000-000000000000";
$ControlInventorylist = GetListByInternalName -listName "Custom"
write-host "ControlInventorylist: " $ControlInventorylist
$ControlInventorylistID = $ControlInventorylist.ID
write-host "ControlInventorylistID: " $ControlInventorylistID
$ControlInventorylistTitle = $ControlInventorylist.Title
write-host "ControlInventorylistTitle : " $ControlInventorylistTitle
$ControlInventoryCTControlID = "0x01006BE13D48B92248419A076BC8F3816F2D00AEF210E6B2F4F74CAD32054F201B6F7B";
$formValueObj = Get-Content "C:\Temp\MyTest_New.xfds";
$formProperty = "fd_MyTest_New"
$formValue = "";
Foreach ($i in $formValueObj){
$formValue += $i.ToString();
}
#Update Site property bag
$rootWeb.AllowUnsafeUpdates = $true;
$rootWeb.AllProperties[$formProperty] = $formValue;
$rootWeb.Update();
$rootWeb.Properties.Update();
$rootWeb.AllowUnsafeUpdates = $false;
$namespace = $srv.getType().namespace;
$formType = New-Object ($namespace + ".Forms");
$srv.PublishForms($ControlInventorylistID, $ControlInventoryCTControlID, $groupID, ($formType.GetType()::New), $true, $formValue); #Change Form type(New, Edit, Display)
$srv.Dispose();
Write-Host -ForegroundColor Green "Form published successfully."
}
Catch
{
Write-Host $_.Exception.Message
}
Cheers
Hi Kurguzov
Great job, It is ok now. Thank you so much
I see you hard code
That mean it must be list title with trim out space characters?
Thanks again.
Dat
Great job, It is ok now. Thank you so much
I see you hard code
Code: Select all
$formProperty = "fd_MyTest_New"
Thanks again.
Dat
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Dat,
Nah, that's not the important addition, I've just copied the previous code. This should work for your case, even if it has spaces:
Nah, that's not the important addition, I've just copied the previous code. This should work for your case, even if it has spaces:
Code: Select all
$formProperty = "fd_"+$ControlInventorylistTitle +"_MyTest_New";
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 4 guests