locked
Can't access fields in hidden tab with javascript in 2013 RRS feed

  • Question

  • In 2011 and earlier, I could access the values of fields in a hidden tab like any other field:

        crmForm.all.new_myfield.DataValue

    However, in 2013, when I try the following:

         Xrm.Page.getAttribute("new_myfield").getValue()

    ... I get the error:

        Unable to get the value of the property 'getValue': object is null or undefine

    Is it not possible to get the values of fields on a hidden tab any more?

    Sunday, February 2, 2014 11:46 PM

Answers

  • Is there a way to close a question? The problem in the title is incorrect, so I'm going to start a new one.
    • Marked as answer by Buddha_Buddy Monday, February 3, 2014 12:57 AM
    Monday, February 3, 2014 12:57 AM

All replies

  • I spoke too soon. It has nothing to do with hidden tabs. I am accessing two fields in the tab. The first one returns null, the other returns an object. They are both DateTime fields, both are set up the same, and both have values that are displayed on the form if I don't hide the tab, but if I "alert()" the value of getAttribute(), only one returns an object. I just don't get it.

        alert("billingdatetime=" + Xrm.Page.getAttribute("new_billingdatetime")); // Prints "billingdatetime=null"
        alert("authorizeddatetime=" + Xrm.Page.getAttribute("new_authorizeddatetime")); // Prints "authorizeddatetime=[Object object]"
        if (Xrm.Page.getAttribute("new_billingdatetime").getValue() != null && Xrm.Page.getAttribute("new_authorizeddatetime").getValue() != null) {

            /// Crashes on above line

        }

    In the form, if I don't hide the tab, the authorized field is editable, and when you mouse over, you get the grey box. However, even though billing is set up exactly the same, and is NOT read-only, it can't be edited, and doesn't even get the grey box that other read-only DateTime fields still get. Looking at the HTML, the billing field doesn't have the div with the "ms-crm-Inline-Edit" class, so for some reason it looks read-only to the CRM, even though it isn't set up that way, and there is no javascript changing it to that. Even so, you should still be able to get the value of a read-only field, shouldn't you?

    Monday, February 3, 2014 12:53 AM
  • Is there a way to close a question? The problem in the title is incorrect, so I'm going to start a new one.
    • Marked as answer by Buddha_Buddy Monday, February 3, 2014 12:57 AM
    Monday, February 3, 2014 12:57 AM
  • Try to use bussines rule in Crm 2013 .

    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Monday, February 3, 2014 6:32 AM
  • Business Rules are still pretty immature. You cannot get context like current user. In this case, I need to look up another entity based on the current user, which is WAY outside of the limited abilities of Business Rules.
    Monday, February 3, 2014 7:55 PM