Form Designer provision
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear dat,
Please, check out this topic, it has information and examples - viewtopic.php?f=1&t=416
Please, check out this topic, it has information and examples - viewtopic.php?f=1&t=416
Cheers
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
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
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear dat,
What URL are you using? Does it also have a port?
What URL are you using? Does it also have a port?
Cheers
Hi Nikita Kurguzov,
Thanks for reply,
Yes, My URL have port. The url like: http://abc-xyz.net:8080/sites/Test
Thanks,
Dat
Thanks for reply,
Yes, My URL have port. The url like: http://abc-xyz.net:8080/sites/Test
Thanks,
Dat
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear dat,
Please, check out the following file as an example of the script that should definitely work. Let me know how it goes!
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
Hi Kurguzov,
I see you hard code
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 by "MyTest" (content type used SPForm), too?
Thanks you so much
I see you hard code
Code: Select all
$ControlInventoryCTControlID = "0x010042CF44740B001F4BB84103EE2C4A89B5";
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"
Thanks you so much
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear dat,
The hardcoded part
is the Content Type ID.
You can retrieve it manually:
The hardcoded part
Code: Select all
$ControlInventoryCTControlID = "0x010042CF44740B001F4BB84103EE2C4A89B5";
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:
Cheers
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
Please help me
Thank you so much
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
}
Thank you so much
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear dat,
Hmm, try it like this:
Let me know what the output would be!
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
}
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 10 guests