//
you're reading...

SharePoint

Self-Service Site Creation Using a Custom Web Template in SPD 2013

How to Use a Custom web Template for a Self-Service Site Creation Workflow in SPD 2013 | www.ConnectorMan.com

In my previous post, I walked through using an SPD 2013 workflow with the Call HTTP Web Service action to create a subsite in SharePoint. In that post, we used Kirk Evans’ sample code, which looks like this:

body: { 'd' :{
     'parameters': {
         '__metadata':  {'type': 'SP.WebInfoCreationInformation' },
         'Url': 'RestSubWeb',
         'Title': 'RestSubWeb',
         'Description': 'rest-created web',
         'Language':1033,
         'WebTemplate':'sts',
         'UseUniquePermissions':false}
     }}

Notice the red text, which sets the WebTemplate to be used. Aravindhan Rajagopal has an easy-to-read table of out-of-the-box WebTemplates. The example shows the name of a Team Site.

But what if you want to use a custom WebTemplate?

Finding and Using a Custom Web Template in the Call HTTP Web Service action in SPD 2013

    1. Open Fiddler (http://www.telerik.com/fiddler).
    2. With session logging on, refresh a browser window where you are logged in to your SharePoint site.
    3. Find the 200 call to your site:
      Find a 200 session in Fiddler
    4. Double-click it to show the Request Headers (top pane on right)
      View Initial Request Headers
    5. Right-click Cookie and select Copy Header:
      Copy Cookie Header
    6. On the Composer tab, create a payload like this (changing “https://www.contoso.com/mypmo” to your site URL):
      POST https://www.contoso.com/mypmo/_api/contextinfo HTTP/1.1
      Accept: application/json;odata=verbose
      Content-type: application/json;odata=verbose
      Host: www.contoso.com
      Content-Length: 0
    7. Paste in the Cookie and delete everything except the FedAuth and rtFa:
      Paste Cookie into Payload
    8. Highlight all of the above and click Execute on the top right of the screen.
      Click to Execute just the highlighted session
    9. Find the response from that session in the window on the left.
      contextinfo Response
    10. Double-click it to see the response (bottom pane on the right). Click the JSON tab (if not already selected):
      JSON response
    11. Find the FormDigestValue in the response object. (Does this look like an SPD 2013 Dictionary to you?)
      Getting the FormDigestValue
    12. Right-click it and select Copy
      Copy FormDigestValue
    13. On the Composer tab, create a payload like this (make sure the GET is pointing to your top-level site collection):
      GET http://www.contoso.com/_api/site/getWebTemplates(1033) HTTP/1.1
      Accept: application/json;odata=verbose
      Content-type: application/json;odata=verbose
      Host: www.contoso.com
      Content-length: 0
    14. Copy the Cookie from your previous session and paste it after the Host line
    15. On the next line, add an X-RequestDigest line and paste the FormDigestValue in it:
      Get WebTemplates with X-RequestDigest
    16. Remove the FormDigestValue= portion highlighted above.
      Get WebTemplates payload
    17. Highlight the entire GET block and click Execute:
      Execute Get WebTemplates
    18. Find the response in the session pane at left (notice the JSON icon; our Accept setting tells REST to give us the Response as JSON):
      JSON response session
    19. Double-click on it to open the response pane (bottom right):
      Get WebTemplates response

      Notice that the second result is the one we used by default: sts, for a Team Site.

    20. Scroll to the bottom to find custom templates that have been saved for the site collection:
      Scroll down to find custom templates
    21. Find the Name of the template you want to use, and right-click on it to select Copy
      Copy WebTemplate GUID and name
    22. Use this value in your SPD 2013 callParams dictionary for the WebTemplate item, when using the Call HTTP Web Service action to create a site.
      Paste WebTemplate GUID and name into SPD

      Be sure to remove the Name= portion highlighted in the image.

    23. Now when your App Step runs, it will use this custom template when creating new sites.

In SharePoint, there is always (or usually) more than one way to do things.

If you’ve read this far and walked through all of the steps, you’ve learned some valuable ways to work with SharePoint and Fiddler, calling REST services and how they’ll work in a workflow.

But next time you want to find the name of a custom web template, there’s a shorter way to get it from the browser.

Alternative Way

    1. Go to Site Contents
      Site Contents
    2. Click new subsite:
      New subsite
    3. In the Template Selection area, click the Custom tab:
      Custom tab
    4. Press F12 to open Internet Tools (on IE) and click the Select element by click button (or right-click and choose Inspect Element [on Chrome and FireFox], and skip to step 6):
      Internet tools
    5. Click the name of your custom template:
      Select custom template
    6. In the Internet tools pane, expand the highlighted select node:
      Expand select
    7. Click the option value for your custom template, and copy that into your workflow:
      Click option value

The Alternative Way makes things easy if you want to hardcode the template to be used. But if you ever need to get the information programatically, you can use the REST call to get it, even from a workflow.

Making the Connection

How are YOU using REST end-points in an SPD 2013 workflow? I’d love to share more examples here.

Discussion

No comments yet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ConnectorMan via Email

Buy My Books

Disclaimer

The views and opinions expressed in the media, articles or comments on this community site are those of the author and do not necessarily reflect or represent the views and opinions held by the advertisers, sponsors, or employer of the author.

Skip to toolbar