Step 1: Goto https://xrmservicetoolkit.codeplex.com/, and download the folder XrmServiceToolkit.
Step 2: Open the XrmServiceToolkit folder, you can find the below Javascript files.
Goto Microsoft Dynamics CRM –> Settings –> Customization –> Webresources.
Create jquery, json2 and XrmServiceToolkit javascript webresources. While creating web resources browse for the respective files and provide the path of XRMServiceToolkit.
Step 3: Add all 3 files to any entity for example the contact entity,
Step 4: Goto Microsoft Dynamics CRM –> Sales –> Contacts, click on Advance find button. Create new criteria as shown below by clicking on New button,
Step 5: Click on Download Fetch XML button, to get FetchXML code. You can see the below XML,
Step 6: We have to change the format of the above FetchXML to use in Javascript.
After modifying its looks like the below,
""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
""
Step 7: Now create new_contactJscript Webresource and paste the below code,
function onLoadContact() {
var contactFetchXML = ""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
""+
"";
var contactRecords = XrmServiceToolkit.Soap.Fetch(contactFetchXML);
if (contactRecords.length > 0) {
if (contactRecords[0].attributes.telephone1 != undefined && contactRecords[0].attributes. fullname!= undefined)
alert(contactRecords[0].attributes. fullname.value +” and ”+contactRecords[0].attributes.telephone1.value);
}
}
Step 8: Add the new_contactJscript Webresource to Form Libraries on contact Form, and add the onLoadContact function to Onload Event,
Step 9: Click on Ok. Save & Publish the contact Entity.
Step 10: Open the existing contact record to see the below pop up,