Form Designer provision

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

14 Jun 2019

Hi Kurguzov,

I run script again. I attached the screenshot for you
SPForms.png
SPForms.png (44.09 KiB) Viewed 2054 times
Thank you so much
Dat

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

14 Jun 2019

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:

Code: Select all

$formProperty = "fd_MyTest_New"
That needs to be changed to:

Code: Select all

$formProperty = "fd_"+$ControlInventorylistTitle +"_MyTest_New"
Try it like this, please.
Cheers

dat
Posts: 13
Joined: Mon May 27, 2019

17 Jun 2019

Hi Kurguzov,

I changed it, but it still show error
SPForm4.png
SPForm4.png (5.37 KiB) Viewed 2044 times
SPForm.png
SPForm.png (27.89 KiB) Viewed 2044 times
Thanks
Dat

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

17 Jun 2019

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?
FormPublishedError.png
FormPublishedError.png (25.67 KiB) Viewed 2043 times
Cheers

dat
Posts: 13
Joined: Mon May 27, 2019

18 Jun 2019

Hi Kurguzov,

Form do not published. I also check form after run script. It still is SharePoint Form.

Thanks

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

19 Jun 2019

Dear dat,
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

dat
Posts: 13
Joined: Mon May 27, 2019

20 Jun 2019

Hi Kurguzov

Great job, It is ok now. Thank you so much
SPForm.png
SPForm.png (31.34 KiB) Viewed 2033 times
I see you hard code

Code: Select all

$formProperty = "fd_MyTest_New"
That mean it must be list title with trim out space characters?

Thanks again.
Dat

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

20 Jun 2019

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:

Code: Select all

$formProperty = "fd_"+$ControlInventorylistTitle +"_MyTest_New";
Cheers

dat
Posts: 13
Joined: Mon May 27, 2019

21 Jun 2019

Hi Kurguzov,

After I run script to provision SPForm success, I check by new item on list. It show ok with Title field that I added in SPForm design file

But It does not anything in design form.
SPForm1.png
SPForm1.png (15.39 KiB) Viewed 2031 times
SPForm2.png
SPForm2.png (38.98 KiB) Viewed 2031 times
Please help me again.

Thanks

dat
Posts: 13
Joined: Mon May 27, 2019

02 Jul 2019

Hi Kurguzov,

Please, can you help me again?

Thanks

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests