web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

I have the same question (0)
  • George Rizk Profile Picture
    7 on at

    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.

  • George Rizk Profile Picture
    7 on at

    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.

  • Suggested answer
    George Rizk Profile Picture
    7 on at

    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]

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans