Question

How do I get the value of a custom field in Microsoft CRM 4.0 with JavaScript?

Here's what works:

This will get me the ID, for the first element in my resources field,

crmForm.all.resources.DataValue[0].id;

This will get the name,

crmForm.all.resources.DataValue[0].name;

Here's what I was expecting to work, but doesn't:

In my resources, I have created a custom field named new_precohora, and was hoping to be able to get it like this,

crmForm.all.resources.DataValue[0].new_precohora;

But for some reason, that field doens't seem to exist.

I can access if i set JavaScript in my Facility/Equipment form. But I wanted to do it from my resources field, located in the Service Activity form.

Thank you in advance!

Was it helpful?

Solution

You cannot access the data of a related record via the lookup field.

The lookup field only provides you the ID and Name of the record, if you wish to get any more information from the record you will need to perform a web service query.

I would suggest looking at this sample: CrmService.Retrieve Method Using JScript

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top