Skip to main content
Nintex Community Menu Bar

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?

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.listsl$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, uMicrosoft.SharePoint.SPTemplateFileType]::FormPage)
$editform = $files.add($editformurl, uMicrosoft.SharePoint.SPTemplateFileType]::FormPage)
$newform = $files.add($newformurl, uMicrosoft.SharePoint.SPTemplateFileType]::FormPage)

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

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

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

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

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

$ilist3.ListId = $list.id
$ilist3.PageType = pMicrosoft.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)
# # ===================

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