cancel
Showing results for 
Search instead for 
Did you mean: 

Space templates - need a copy not a reference

rhowlett
Champ in-the-making
Champ in-the-making
I am using JavaScript to dynamically include space templates, but am getting a reference to the space template and not a copy. In other words when I add content into the copied space, the item also appears in the template space.

templateProject is a Space Template in the Data Dictionary
destinationSpace is the folder where I want the template copied to

//Copy the template project into the destination space
var newProjectSpace = templateProject.copy(destinationSpace);

Any ideas?
6 REPLIES 6

kevinr
Star Contributor
Star Contributor
Are you saying that the 'newProjectSpace' variable references the original templates spaces not the newly created space?

rhowlett
Champ in-the-making
Champ in-the-making
Yes. However I noticed this happens when I copy a space template into a  space that itself was created as a copy of a space template.
Example:

Data Dictionary
…Space Templates
……Vehicle Space
………Automobile Space
…………Ford (problem: it appears here though created in a copied space)
     
Company Home
…Vehicle Space
……Automobile Space
…………Ford (content item)

kevinr
Star Contributor
Star Contributor
I will see if i can reproduce this issue - and raise a bug for it as required.

Thanks,

Kevin

rhowlett
Champ in-the-making
Champ in-the-making
Ok thanks. BTW the configuration looks more like this:

Data Dictionary
…Space Templates
……Vehicle Space
……Truck Space
……Automobile Space
……..Ford (problem: it appears here though created in a copied space)

Company Home
…Vehicle Space
……Automobile Space
…………Ford (content item)

The Vehicle space gets copied, then depending on circumstances a Truck or Automobile space is created beneath the Vehicle space. If content items are created in Company Home/Vehicle Space, they do not appear in the Data Dictionary. The 'copy by reference' problem appears with the reused Automobile (or Truck) spaces.

kevinr
Star Contributor
Star Contributor
Can you post a few more details? I'm still not quite sure of the exact sequence of steps and the exact folder structure. You could post the script/rules that you are using?

Thanks,

Kevin

rhowlett
Champ in-the-making
Champ in-the-making
Here is a script I am using to setup a client.

//============================================
// Name: setupCompany.js
// Description: Sets up a client space
//============================================

//Get a reference to the space where clients reside
var spaceName = "Extranet/Clients";
var clientsSpaces = companyhome.childByNamePath(spaceName);

//Get a reference to the company space template
var templateName = "Data Dictionary/Space Templates/Company";
var templateCompany = companyhome.childByNamePath(templateName);

//Copy the company template into the clients space
var newClientSpace = templateCompany.copy(clientsSpaces);

//Rename the current item
document.properties.name = "Company Profile";
document.save();

//Name the client space
newClientSpace.properties.name = document.properties.title;
newClientSpace.save();

//More the current item into the new space
document.move(newClientSpace);