how to programatically create child incidents that use mappings? RRS feed

  • Question

  • Hello, I have an incident relationship in place, with mappings, that copy certain fields from parent to child, when using the standard CRM UI to create child incidents.

    However, I have a new requirement, where I need to create new child incidents programatically.  What is the proper way to programatically create a child incident from a parent incident?  

    Essentially, CRM needs to know, that when a particular child case is created, that it was created from a particular parent, and then apply the field mappings appropriately?

    Friday, November 15, 2013 8:49 PM

All replies

  • One way to accomplish this would be to create a plugin. On creation of the child record you can retrieve the values of the parent record and set them to the child record.

    I included a little bit of code as an example. In this case I create a new custom entity record and set the values to the fields in that custom record.

    Entity lineItem = new Entity("new_salescommissionslineitems");
    lineItem["new_name"] = name + " " + getuom;
                                    lineItem["new_salessplit"] = new EntityReference("new_salescommissions", new Guid(c.Id.ToString()));
                                    lineItem["ownerid"] = c["ownerid"];
                                    lineItem["new_splitpercentage"] = splitPerc;
                                    lineItem["new_commissonableamount"] = itemAmount;
                                    lineItem["new_commissionaftersplit"] = commissionableamount;

    Friday, November 15, 2013 9:14 PM