Form Designer provision

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
dat
Posts: 13
Joined: Mon May 27, 2019

28 May 2019

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

31 May 2019

Dear dat,
Please, check out this topic, it has information and examples - viewtopic.php?f=1&t=416
Cheers

dat
Posts: 13
Joined: Mon May 27, 2019

05 Jun 2019

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

06 Jun 2019

Dear dat,
What URL are you using? Does it also have a port?
Cheers

dat
Posts: 13
Joined: Mon May 27, 2019

07 Jun 2019

Hi Nikita Kurguzov,

Thanks for reply,

Yes, My URL have port. The url like: http://abc-xyz.net:8080/sites/Test

Thanks,
Dat

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

07 Jun 2019

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
} 

Cheers

dat
Posts: 13
Joined: Mon May 27, 2019

11 Jun 2019

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

11 Jun 2019

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
ctypeID.png (16.47 KiB) Viewed 2208 times
As for Item, yes, you'll need to replace it with the name of your Content Type.
Cheers

dat
Posts: 13
Joined: Mon May 27, 2019

12 Jun 2019

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
SPForm3.png (10.8 KiB) Viewed 2204 times
SPForm2.png
SPForm2.png (35.34 KiB) Viewed 2204 times
SPForm1.png
SPForm1.png (58.78 KiB) Viewed 2204 times
Please help me

Thank you so much

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

13 Jun 2019

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!
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests