We are provisioning sites programmatically from a remote event receiver (user enters project information in a list and site is provisioned from code) in SharePoint Online. We want to provision a list with New, Edit and Display forms customized. Is there any easy way to do this in SharePoint online?

I'm provisioning list this way:

public static void ProvisionListProjectStatus(Web web)
        if (!web.ListExists(ProjectStatusListName))
            List list = web.CreateList(
                listType: ListTemplateType.GenericList,
                listName: ProjectStatusListName,
                enableVersioning: false,
                enableContentTypes: true);

            if (!web.ContentTypeExistsByName(ProjectStatusListName, ContentTypeManager.PWSProjectStatusName))
                    listTitle: ProjectStatusListName,
                    contentTypeId: ContentTypeManager.PWSProjectStatusId,
                    defaultContent: true,
                    searchContentTypeInSiteHierarchy: true);

            if (web.ContentTypeExistsByName(ProjectStatusListName, ContentTypeManager.ItemName))
                ContentType itemContentType = web.GetContentTypeById(
                    contentTypeId: ContentTypeManager.ItemId,
                    searchInSiteHierarchy: true);
                web.RemoveContentTypeFromList(list, itemContentType);

            if (list.FieldExistsByName(SiteColumnManager.TitleInternalName))
                FieldCollection fields = list.Fields;
                Field titleField = fields.GetByInternalNameOrTitle(SiteColumnManager.TitleInternalName);
                titleField.Title = SiteColumnManager.ProjectStatusPeriodDisplayName;
  • are you provisioning site based on any custom site template? – Atish Dipongkor - MVP Nov 6 '15 at 11:33
  • It's SharePoint Online, so I am provisioning site programmatically with CSOM from remote event receiver. – Alfonso Nov 6 '15 at 15:42
  • Can you show your CSOM code? – Atish Dipongkor - MVP Nov 6 '15 at 17:00

You can provision a site with custom list forms by following way

  • Create a site like My Custom Provisioned
  • Create yours list in this site
  • Now customize your forms (New, Edit and Display)

Now save this site as Template and use this template in remote event receiver to create new site.

  • Remote event receiver is located in Azure web app (it is a Provider Hosted app for SharePoint Online). Templates cannot be used in SharePoint Online as far as I know. – Alfonso Nov 6 '15 at 15:43
  • I do not agree that template can not be used in SPO. You need the template id to create a new site using REST API , JSOM or CSOM nothing else. – Atish Dipongkor - MVP Nov 6 '15 at 16:46
  • Can you show your CSOM code? I guess currently you are using Team Site Template Id to create new site. Instead of that Id, now you have to use custom template Id. That's all – Atish Dipongkor - MVP Nov 6 '15 at 16:58
  • I have updated question with code provisioning list. – Alfonso Nov 6 '15 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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