locked
getAttribute() returns null even though name is correct RRS feed

  • Question

  • I have two DateTime fields in a hidden tab. I need to do some calculations on them in the onload handler when both are populated, but one always returns null when I call getAttribute() on it, even though I know it is on the page and has data.

        alert("billingdatetime " + Xrm.Page.getAttribute("new_billingdatetime")); // prints "billingdatetime null"
        alert("authorizeddatetime " + Xrm.Page.getAttribute("new_authorizeddatetime")); // prints "authorizeddatetime [Object object]"

    Both fields are set up identically in the entity, and both are set up identically on the form as well. Both are visible and NOT read-only, and both are on the same hidden tab. It doesn't matter if the tab is hidden or not. However, the billingdatetime field is NOT editable. It doesn't even get the grey box outline on mouseover that other read-only fields still get.

    I don't understand what is going on here.

    Monday, February 3, 2014 1:06 AM

Answers

  • This ended up being some kind of corruption in the form XML. CRM Support has seen it before, and the fix was pretty simple. I just created a new Form. It was a copy of the existing Form (I didn't specify that it should copy the form, it just did). It already had all the scripts and events attached, I just needed to fix the Security Roles.
    • Marked as answer by Buddha_Buddy Wednesday, February 5, 2014 1:22 AM
    Wednesday, February 5, 2014 1:22 AM

All replies

  • Hi

    Try using..

    Xrm.Page.data.entity.attributes.get("new_billingdatetime").getValue();

    Hope this helps.

    Monday, February 3, 2014 5:19 AM
  • use

    Xrm.Page.getAttribute("new_billingdatetime").getValue();

    check it..


    ms crm

    Monday, February 3, 2014 6:23 AM
  • Xrm.Page.getAttribute() is just a shortcut to Xrm.Page.data.entity.attributes.get(). It has the same problem. The problem isn't with the way I am accessing it. The problem is that any field beyond the ninth one is just plain text, and not a control.
    Monday, February 3, 2014 7:40 PM
  • That is what I used. See the code in my original post.
    Monday, February 3, 2014 7:40 PM
  • This ended up being some kind of corruption in the form XML. CRM Support has seen it before, and the fix was pretty simple. I just created a new Form. It was a copy of the existing Form (I didn't specify that it should copy the form, it just did). It already had all the scripts and events attached, I just needed to fix the Security Roles.
    • Marked as answer by Buddha_Buddy Wednesday, February 5, 2014 1:22 AM
    Wednesday, February 5, 2014 1:22 AM