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)

Unable to access Iframe control in crm 2016 form

(0) ShareShare
ReportReport
Posted on by

Hello Expert,

I am upgrading crm 2011 to crm 2016 onpremise, due to new rendering engine of newer version so many javascript code is not working. Recently getting issue with iframe where I am unable accessing iframe contents using JQuery.

var ccControl = $("#WebResource_ccCheckList").contents().find(":checkbox");
 if(ccControl)
{
 //Business Logic
} 
The element I want to access is an html input with id of '
myChckboxId':
 <input id="myChckboxId" type="checkbox"><label>Are you Agree ?</label>
getting ReferenceError: '$' is undefined Error although $ reference working fine with scripted in IFrame.

tried following workaround to fix but not working for me :

1)Put following script on onload.

if (typeof($) === 'undefined'){
	var script = document.createElement('script');
	script.src = 'ajax.googleapis.com/.../jquery.min.js';
	script.async = false; 
	document.head.appendChild(script);}

2)

$(Xrm.Page.ui.controls.get('WebResource_ccCheckList').getObject()).contents().find(':checkbox').val();

Xrm.Page.ui.controls.get('WebResource_ccCheckList').getObject() is giving me obj but not works with $.

3)

Xrm.Page.ui.controls.get("WebResource_ccCheckList").getObject().contentWindow.document.getElementById('myChckboxId');

Getting Null

Please suggest any alternate approach to resolve the issue.

Thanks

*This post is locked for comments

I have the same question (0)
  • Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Hi,

    Can you tell when are you getting this error? And what are you setting in your iFrame?

    Also, do you want to access the iframe control added on the form using JavaScript?

    FYI: Accessing DOM elements is no more supported.

  • Community Member Profile Picture
    on at

    Thanks Yadnyesh for your response, FYI I am getting this error onLoad event of Case entity. Actually I have an IFrame on the CRM form containing checkbox that check box status I need to check, Please see my first code block mentioned in the question. On the basis of that checkbox I need to toggle some fields on the CRM Form.

    Please suggest any alternate way to support my business need if accessing the DOM is not supported, I have less experience on CRM 2016.

    Thanks

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Any specific reason to use IFrame? Can you use two options field on case entity based on which you can toggle the fields?

  • Community Member Profile Picture
    on at

    Sorry we can not replace IFrame because there are other stuff on that IFrame being used for different business.

    Thanks

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