0

I've followed one of the tutorials to use CSOM (JavaScript) to work on a list. I need to template the site and create new sites from it.

But in my code (CEWP and txt file) I have a hard coded link. Is it somehow possible to change to grab site collection (itdevSC) ?

var siteUrl = '/sites/itdevSC/mysubsite';     
var clientContext = new SP.ClientContext(siteUrl);
Robert Lindgren
  • 24,520
  • 12
  • 53
  • 79
Orange Juice Jones
  • 1,535
  • 2
  • 29
  • 65

1 Answers1

0

You can get the URL using

var siteUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
Amal Hashim
  • 28,306
  • 5
  • 31
  • 61