- Microsoft Dynamics CRM Resource Center
- Microsoft Dynamics CRM Forums
- Microsoft Dynamics CRM Community
- XRM Virtual User Group
- Microsoft Dynamics CRM Developer Center – MSDN
- Microsoft Dynamics CRM MVP’s
…… just to mention a few.
First and foremost, the Dynamics CRM developer community is very active and generally more than happy to share code so I leverage it with great appreciation. A couple of my frequently visited web sites include:
The following code example shows how to use a Customer field type.
var customer = new Array();
customer = null;
// This gets the lookup for the attribute customerid on the Opportunity form.
customer = crmForm.all.customerid.DataValue;
// If there is data in the field, show it in a series of alerts.
if (customer != null)
// The name of the customer.
// The GUID of the customer.
// The entity type name of the customer.
Since the Customer is a linked entity to the Opportunity and the code snippet shows how to obtain the “Name” value of the linked Customer, I knew with a few tweaks, I could make this code work to obtain the Product Name & then update the Title field of the Contract Line with that value.
Following is the modified script I used to update the Contract Line field
// set the value of the Contract Line title field = linked product name
product = crmForm.all.productid.DataValue;
if (product != null)
crmForm.all.title.DataValue = product.name;
I placed the code above in the OnChange event of the Title field and placed the following in the OnChange event of the Product lookup field.
I also changed the Product field to required and updated the Dependency fields where I applied script. Another recommendation is to change the order of the fields so that the Product field is one of the first fields that the user encounters when opening or creating a record. This minimizes that chance that a user will unnecessarily enter a value in the field just to have it overwritten by the script.
You can use the above example for auto-updating almost any entity “Title” type field in CRM like Opportunities, Cases, etc. This is one option for gaining consistency for these field type values. Since the Title / Topic type fields are required fields for many entities, and are often the primary field displayed in lookups, it can add value to have specified naming conventions that are automatically updated for the end user. You can easily string values together to create a consistent & useful field value.