Hi, A one to many relationship is basically a lookup. You have to set the value of the lookup. This can be done from either JavaScript or plugin code. The target record in both cases must exist. In JavaScript (one of the ways), you can call the following function, and pass the parameters as required: // fieldname: the attribute that you want to set // lookupid: the unique identifier of the relationship // lookupname: the text of the identifier // entityname: the logical name of the entity function setLookupField(fieldName, lookupId, lookupName, entityName) { var lookupData = new Array(); var lookupItem = new Object(); lookupItem.id = lookupId; lookupItem.name = lookupName; lookupItem.entityType = entityName; lookupData[0] = lookupItem; Xrm.Page.getAttribute(fieldName).setValue(lookupData); } In C#/Plugin code entity[lookupFieldName] = new EntityReference(id_of_lookup, targetEntityName); Hope this helps.
↧