Cry about...
Dynamics CRM 2011 How To
How to get and set the value of a field (JavaScript)
A field is accessed via the getAttribute
function:
var field = Xrm.Page.getAttribute("fieldname");
Then to get the value of the field:
var value = field.getValue();
to set the value of the field:
field.setValue(newValue);
These are normally done on a single line rather than broken down into steps, i.e.:
var oldValue = Xrm.Page.getAttribute("someField").getValue();
Xrm.Page.getAttribute("someField").setValue("newValue");
You might also find the following notes useful:
These notes have been tested with Microsoft Dynamics CRM 2011, and may apply to other versions as well.
About the author: Brian Cryer is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.