The JavaScript SDK is not the clearest on this point, but the basics of it is that the SDK does not allow direct insertion into intersect tables. It only allows calls to the Associate
method. Below are two TechNet links which may lead you in the right direction.
Additionally, Avanade has done a wonderful job in making a CRM JavaScript library (updated to reference archive.org) publicly available which includes an Associate
helper method.
Finally, some sample code:
function AssociateEntities(moniker1, moniker2, relationshipName) {
var xml;
var resultXml;
xml = "<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>";
xml += "<Request xsi:type='AssociateEntitiesRequest'>";
xml += "<Moniker1><Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>" + moniker1[0].id + "</Id>";
xml += "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>" + moniker1[0].entityType + "</Name></Moniker1>";
xml += "<Moniker2><Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>" + moniker2[0].id + "</Id>";
xml += "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>" + moniker2[0].entityType + "</Name></Moniker2>";
xml += "<RelationshipName>" + relationshipName + "</RelationshipName>";
xml += "</Request></Execute>";
resultXml = CallCrmService(xml, "Execute");
if (resultXml) {
return "success";
}
else {
return null;
}
}