Page 1 of 3
Form Designer provision
Posted: 28 May 2019
by dat
Hi,
I am using SharePoint 2016 with SP Form Designer.
I need to import SP Form from “Item_New.xfds”, “Item_Edit.xfds” and “Item_Display.xfds” files in SharePoint list using SharePoint Server PowerShell
Can you show me the sample code
Thank you so much
Re: Form Designer provision
Posted: 31 May 2019
by Nikita Kurguzov
Dear dat,
Please, check out this topic, it has information and examples -
viewtopic.php?f=1&t=416
Re: Form Designer provision
Posted: 05 Jun 2019
by dat
Hi Nikita,
I tried the sample code as topic that you give me (
viewtopic.php?f=1&t=416&start=10).
But It always show error ""List does not exist".
It is same error of Dikesh310 posted
viewtopic.php?f=1&t=416&start=20
Please help me,
Thanks
Re: Form Designer provision
Posted: 06 Jun 2019
by Nikita Kurguzov
Dear dat,
What URL are you using? Does it also have a port?
Re: Form Designer provision
Posted: 07 Jun 2019
by dat
Hi Nikita Kurguzov,
Thanks for reply,
Yes, My URL have port. The url like:
http://abc-xyz.net:8080/sites/Test
Thanks,
Dat
Re: Form Designer provision
Posted: 07 Jun 2019
by Nikita Kurguzov
Dear dat,
Please, check out the following file as an example of the script that should definitely work. Let me know how it goes!
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 = 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"
$groupID = [Guid]"00000000-0000-0000-0000-000000000000";
$ControlInventorylist = GetListByInternalName -listName "B"
$ControlInventorylistID = $ControlInventorylist.ID
$ControlInventorylistTitle = $ControlInventorylist.Title
$ControlInventoryCTControlID = "0x010042CF44740B001F4BB84103EE2C4A89B5";
$formValueObj = Get-Content "C:\MyFolder\Plumsail\Item_New.xfds";
$formProperty = "fd_"+$listTitle+"_Item_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
}
Re: Form Designer provision
Posted: 11 Jun 2019
by dat
Hi Kurguzov,
I see you hard code
Code: Select all
$ControlInventoryCTControlID = "0x010042CF44740B001F4BB84103EE2C4A89B5";
I still hard code like you when run that script? If not, please show me how to get that value.
Note: I created new content type for the list used SPForm Designer (Ex:
MyTest). I used that content type as default content type. I still used you suggest code to provision for form used MyTest content type?
I also need change "
Item" in this line
Code: Select all
$formProperty = "fd_"+$listTitle+"_Item_New"
by "MyTest" (content type used SPForm), too?
Thanks you so much
Re: Form Designer provision
Posted: 11 Jun 2019
by Nikita Kurguzov
Dear dat,
The hardcoded part
Code: Select all
$ControlInventoryCTControlID = "0x010042CF44740B001F4BB84103EE2C4A89B5";
is the Content Type ID.
You can retrieve it manually:
- Go to List Settings
- Click Advanced settings
- Select Yes under Allow management of content types? Click Okay.
- Go back to List Settings
- Open the content type. SharePoint will reference the ContentTypeId in the URL:
- ctypeID.png (16.47 KiB) Viewed 2211 times
As for
Item, yes, you'll need to replace it with the name of your Content Type.
Re: Form Designer provision
Posted: 12 Jun 2019
by dat
Hi Kurguzov,
I tried provision SPForm as your suggest code but it still show List does not exist error.
Bellow my code that I run and some screenshots
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"
$groupID = [Guid]"00000000-0000-0000-0000-000000000000";
$ControlInventorylist = GetListByInternalName -listName "Custom"
write-host "ControlInventorylist: " $ControlInventorylist
$ControlInventorylistID = $ControlInventorylist.ID
$ControlInventorylistTitle = $ControlInventorylist.Title
$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
}
- SPForm3.png (10.8 KiB) Viewed 2207 times
- SPForm2.png (35.34 KiB) Viewed 2207 times
- SPForm1.png (58.78 KiB) Viewed 2207 times
Please help me
Thank you so much
Re: Form Designer provision
Posted: 13 Jun 2019
by Nikita Kurguzov
Dear dat,
Hmm, try it like this:
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"
$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
}
Let me know what the output would be!