Monday 26 October 2015

Associate Records with the Record of Different Entity using java script


Hi All,

As a very common requirement, I was asked to implement the functionality to associate a record in CRM 2015 just to associate the existing record to the record of different entity.

To get this work done First you need to add SDK.REST.js library to your script.

Link to download Sdk.Rest

Then copy paste this code and pass the parameter value as required.

function associateRecord (parentId, childId) {

           SDK.REST.associateRecords(
                                          parentId,                                  //Guid of parent record
                                         "new_contactlist",                       // Schema Name of Parent Entity
                                          "new_contactlist_sevaprofilenew",  //Relationship Schema Name
                                          childId,                                    // Guid of Child Record
                                          "new_sevaprofilenew",             // Schema Name of Child entity
           
                       function () {
                                        alert("Association successful.");
                                        },
                       function () {
                                      alert("Record Already Found");
                                     });
        }

To get a lookup record of parent Entity in your script .

Please refer my previous Blog
http://crmpankaj.blogspot.in/2015/10/create-custom-dialog-lookup-values-for.html

Hope this would be very helpful to you in your development.

No comments:

Post a Comment