Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

getattribute returns a null value when trying to retreive information from a Quick View Form in CRM 2016

(0) ShareShare
ReportReport
Posted on by 7

Hi All,

Just to confirm that I have run the following code through the Code Validation tool and all checks out well. I have also confirmed that this code works well when I use the "Legacy Form Rendering Engine"

Note: I am using CRM 2016 On-Premise and the following is running "OnLoad" using the Case Form. I have a Quick View Form on the Case form which I am trying to retreieve some information from.

function Iframe_OnReadyStateComplete() {
    var iFrame = Xrm.Page.ui.controls.get('IFRAME_COLOR');
    var serverUrl = iFrame.getSrc();
    if (serverUrl.indexOf("about:blank") != -1) {
        setiFrameUrl();
    }
}

function setiFrameUrl() {
     var iframeObject = Xrm.Page.getControl("IFRAME_COLOR");
     var entityName = Xrm.Page.data.entity.getEntityName();
     var serverUrl = Xrm.Page.context.getClientUrl() + '/WebResources/';
     var controlName = Xrm.Page.getControl("remote_support_member_qv1_remote_support_member_qv1_account_new_remotesupportmember").getAttribute().getValue();
     if (controlName == false) {
         // Set Color Bar Red
         iframeObject.setVisible(true);
             iframeObject.setSrc(serverUrl + 'new_colorBarRed');
     }
     else {
         iframeObject.setVisible(true);
         if (controlName == true) {
             // Green Color
             iframeObject.setSrc(serverUrl + 'new_colorBarGreen');
       }
     }
 }


What happens in the above code is that it changes the contents of an iFrame on the Case form depending on the value retrieved in the "var controlName" section. The "var controlName" is retreieving the value from a Quick View Form which is on the Case Form. The exact error is this:

TypeError: Unable to get property "getAttribute" of undefined or null reference at SetIframeUrl

This works very well when used in legacy forms rendering but is not working with new Forms rendering engine yet the code is validated perfectly.

I am suspecting a bug in the new Forms Rendering Engine which for some reasons always returns a null value when trying to retreive a value from a Quick View Form.

Here is an example of how it works:

mahadeomatre.blogspot.com.au/.../access-quick-view-form-values-in.html

Anyone have any ideas or an alternative solution to get the same thing working in the new Forms Rendering Engine?

*This post is locked for comments

  • Suggested answer
    George Rizk Profile Picture
    7 on at
    RE: getattribute returns a null value when trying to retreive information from a Quick View Form in CRM 2016

    Think I found the answer:

    [View:http://blogs.msdn.com/b/emeadcrmsupport/archive/2015/09/24/dynamics-crm-how-to-access-a-quickform-component-via-jscript-in-turbo-forms.aspx]

  • George Rizk Profile Picture
    7 on at
    RE: getattribute returns a null value when trying to retreive information from a Quick View Form in CRM 2016

    I have done some further testing using a MSDN simple Java script and still I am not able to retrieve the value of a Quick View Field when enabling the new forms rendering Engine.

    https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_getAttribute

    Here is Microsoft's test JS for getting information from a Quickview but it doesn't work in CRM 2016 with the new forms rendering engine:

    The following code shows using the value the contact mobilephone attribute when displayed on an account entity form using a quick view control named contactQuickForm. This code hides the control when the value of the attribute is null.

    Copy
    var quickViewMobilePhoneControl = Xrm.Page.getControl("contactQuickForm_contactQuickForm_contact_mobilephone");
     if (quickViewMobilePhoneControl.getAttribute().getValue() == null)
     {
      quickViewMobilePhoneControl.setVisible(false);
     }
    

    ======

    Here is the test script for my use based on my original post:

    function testjs() {
    var controlName = Xrm.Page.getControl("remote_support_member_qv1_remote_support_member_qv1_account_new_remotesupportmember").getAttribute().getValue();
    alert(controlName);
    }


    What my test is meant to do is display a popup box of the value contained in the Quick View Form. It's not returning the value and the script is erroring out with the same error I provided in the original post.

    This script works in Legacy Form Rendering Engine but not in the new forms rendering engine.

    Can someone please shed some light on this and test? I am beginning to think this is a bug in CRM 2016 with new forms rendering engine enabled.

    If any MS employee's are monitoring this forum would appreciate some expert feedback if possible.

  • George Rizk Profile Picture
    7 on at
    RE: getattribute returns a null value when trying to retreive information from a Quick View Form in CRM 2016

    Here is another good working example of access a "Quick View Form" from within the Parent Form.

    community.dynamics.com/.../access-microsoft-dynamics-crm-quick-view-form-attributes-using-javascript

    From what I have been reading so far it appears the way Javascript is fired off in the new Form Rendering Engine is breaking the code. However if the code is validated to work correctly how else can this be achieved?

    I am using Legacy Form Rendering till a good working solution is found.

    Am keen to get this working correctly as I am sure many people out there are using Javascript to access Quick View Forms and want it working in the new Forms Rendering Engine.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,017 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,852 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans