Forum Discussion
assuming 'this' is the item you wish to save, I would suggest you try something similar to:
//Get the related_id
var sp_target_id = this.getRelationship("SP Target").getRelatedItemID(); //assumes 1 relationship item of type "SP Target"
//create the relationship Item
var target_string = "<Relationships>";
target_string += "<Item type='AP Initiative Target' action='add'>";
target_string += "<related_id>" +sp_target_id+ "</related_id>";
target_string += "</Item>";
target_string += "</Relationships>";
//Load the AML into a new Item
Var targ = this.newItem();
targ.loadAML(target_string)
//Add the relationship to the context items AML
this.addRelationship(targ);
Note: I have not tested this, but it shows the approach I would take if I was to do something similar.
Many thanks,
Martin