I could achieve this i.e. creating a list's NewForm named CustomNewForm.aspx setting it as Default NewForm and editing it in advanced mode to add a script code which redirects to CustomForm.aspx Page using code
window.location.href = "/sites/<Site Collection Name>/SitePages/CustomForm.aspx"

Using SharePoint Designer but as per deployment is concerned I need to achieve this using Powershell only. Is there a way to do the above two steps using Powershell or is there a better solution to achieve the task of mainly to redirect to CustomForm Page (The CustomForm.aspx page has custom UI and consist of jsom code to create a new ListItem) for creating new item in the list and making it available on the click of New item button.

  • Do you want to redirect after item is saved? Commented Jun 19, 2017 at 6:11
  • No before, actually at page load itself Commented Jun 19, 2017 at 6:13
  • searched for creating a list form using powershell didn't get relevant solutions Commented Jun 19, 2017 at 6:15
  • What is your environment SPO or SP on-prem? Commented Jun 19, 2017 at 6:20
  • SPO environment Commented Jun 19, 2017 at 6:25

1 Answer 1


Use the following CSOM code to update the NewFormUrl property of the list item content type.

            ClientContext ctx = new ClientContext("http://spm:5002/sites/test");
            Web web = ctx.Web;
            List test = web.Lists.GetByTitle("TestList");
            ContentTypeCollection ct = test.ContentTypes;

            ContentType item = ct.Where(x => x.Name.Equals("Item")).FirstOrDefault();
            Console.WriteLine(item.Name + ", " + item.Id + ", " + item.NewFormUrl);
            item.NewFormUrl = "SitePages/asd.aspx";

Now whenever you click on New Item it will open the desired page. Also note that item.Update(false); statement is going to update the content type. The false as function parameter used to not update the derived content type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.