Solved

Published Nintex form not replacing NewForm.aspx

  • 31 December 2015
  • 3 replies
  • 147 views

Badge +2

We have a list that has a Nintex form that only replaces the DispForm.aspx and EditForm.aspx but not the NewForm.aspx.  We want it to replace all three as is normal.  We first thought the problem was the fact that the list is missing the original-from-SharePoint NewForm.aspx form but creating a new NewForm.aspx and making that the default didn't solve the problem.  How can we get the published Nintex form to replace the SharePoint NewForm.aspx?

icon

Best answer by beth_massie 8 January 2016, 19:50

View original

3 replies

Badge +2

We had to recreate the original NewForm.aspx page which cannot be done through SharePoint Designer (you can create a new NewForm.aspx but it won't work with Nintex) and couldn't be restored from backup as it had been deleted further back than our backups reached).  Instead, run the script found at http://blogs.technet.com/b/yashgoel-msft/archive/2013/08/30/recreating-default-display-edit-and-new-forms-of-a-list-in-s…  in PowerShell.  The script below was originally posted at the above address by Yash Goel on 30 Aug 2013 and reproduced here only in case the link breaks.

Following script recreates dispform.aspx, editform.aspx and newform.aspx of a list using PowerShell, useful in scenarios where we need to recreate these forms to fix issues induced due to upgrades

$url = Read-Host "Enter URL" 

do{
$listname = Read-Host "Enter List Name"
$web = get-spweb $url
$list = $web.lists[$listname]
$files = $list.rootfolder.files

#---------------------------- Delete Forms ----------------------

$form1 = $list.RootFolder.files | ?{$_.url -match "dispform.aspx"}

$form2 = $list.RootFolder.files | ?{$_.url -match "editform.aspx"}

$form3 = $list.RootFolder.files | ?{$_.url -match "newform.aspx"}

$form1.delete()
$form2.delete()
$form3.delete()

$list.update()

# --------------------------recreating --------------------------------

$editformurl = $list.RootFolder.ServerRelativeUrl + "/EditForm.aspx"
$dispformurl = $list.RootFolder.ServerRelativeUrl + "/DispForm.aspx"
$newformurl = $list.RootFolder.ServerRelativeUrl + "/NewForm.aspx"

$dispform = $files.add($dispformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage)
$editform = $files.add($editformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage)
$newform = $files.add($newformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage)

$wpm = $editform.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$wpm2 = $dispform.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$wpm3 = $newform.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

$lfw1 = new-object ([Microsoft.SharePoint.WebPartPages.ListFormwebpart])
$lfw2 = new-object ([Microsoft.SharePoint.WebPartPages.ListFormwebpart])
$lfw3 = new-object ([Microsoft.SharePoint.WebPartPages.ListFormwebpart])

$ilist1 = [Microsoft.SharePoint.WebPartPages.IListWebPart]($lfw1)
$ilist2 = [Microsoft.SharePoint.WebPartPages.IListWebPart]($lfw2)
$ilist3 = [Microsoft.SharePoint.WebPartPages.IListWebPart]($lfw3)

$ilist1.ListId = $list.id
$ilist1.PageType = [Microsoft.SharePoint.PAGETYPE]::PAGE_EDITFORM;

$ilist2.ListId = $list.id
$ilist2.PageType = [Microsoft.SharePoint.PAGETYPE]::PAGE_DISPLAYFORM;

$ilist3.ListId = $list.id
$ilist3.PageType = [Microsoft.SharePoint.PAGETYPE]::PAGE_NEWFORM;

$wpm.AddWebPart($lfw1, "Main", 1)
$wpm2.AddWebPart($lfw2, "Main", 1)
$wpm3.AddWebPart($lfw3, "Main", 1)


$list.DefaultDisplayFormUrl = $dispformurl
$list.DefaultEditFormUrl = $editformurl
$list.DefaultNewFormUrl = $newformurl

$list.update()
}
while ($TRUE)
# # ===================
Badge +7

Very interesting. We had a similar issue and I deleted the list and recreated it. I gave up trying to figure it out.

Hi and thank you for sharing this with us.


 


I tried running the script but it fails all the time and I have no clue why. It says the 


$form1,2,3 

 are empty values but I put the correct Information at URL and list... do you maybe have an idea why this happens?


 


thanks in advance

Reply