Search code examples
javascripthtmldynamics-crm-2011xrm

Why getAttribute returns null?


I am using dynamics CRM. I have created one HTML web resource and added to Contacts form. Code,

<html>
<head>
    <title>OData</title>
    <meta charset="utf-8">
</head>
<body>
    <script type="text/javascript">
        function getAllAttribute() {

            document.getElementById("demo").innerHTML = Xrm.Page.getAttribute();
        }
    </script>
    <button onclick="getAllAttribute();">Attributes!</button>
    <p id="demo">Value will be displayed here</p>
</body>
</html>

Now, when I click on Attributes! button, demo paragraph gets null, why it is not giving names of all attributes on page?


Solution

  • may be use window.parent.Xrm.Page.data.entity.attributes or window.parent.Xrm.Page.getAttribute() instead of Xrm.Page.getAttribute();.

    see here:http://msdn.microsoft.com/en-in/library/gg328474.aspx