Description:
In this example we explain that how to populate
the Lead information like First Name and Last Name based on Existing Customer
in Lead Form in Dynamic CRM using JavaScript. Or how to bind First Name and Last
Name in Lead form based on the selection of the Existing Customer in Dynamic
CRM using JavaScript. Or setting Lead Name based on Existing Customer in
dynamic CRM.
Here we demonstrate how to populate or
bind Lead field information automatically based on Existing Customer Lookup
change or how to fill up or populate details based on onChange of the Lookup of
the existing Customer in dynamic crm using JavaScript.
So how to fill up First Name and Last Name
based on the Existing Contact lookup.
Call this below function on the onChange of the Lookup of the Existing Contact.
Javascript Code:
function ParentContactId_OnChange()
{
if (Xrm.Page.getAttribute("parentcontactid") != null)
{
var ContactId = Xrm.Page.getAttribute("parentcontactid").getValue()[0].id;
//utilize retrieveRecord method from REST library to get data based on contact id
SDK.REST.retrieveRecord(
ContactId,
"Contact",
null, null,
function(contact)
{
//once we have data fill name fields
Xrm.Page.getAttribute("firstname").setValue(contact.FirstName);
Xrm.Page.getAttribute("lastname").setValue(contact.LastName);
Xrm.Page.getAttribute("fullname").setValue(contact.FirstName + " " + contact.LastName);
},
function Error()
{
alert("There is error in reading contact data");
});
}
}
0 comments:
Post a Comment