Skip to main content
Community site session details

Community site session details

Session Id :
Customer Service forum

Dynamics CRM Portals - Cross origin frame issue

(0) ShareShare
ReportReport
Posted on by 480

Hello Everyone,

In one of my web form steps I am trying to prepopulate a Lookup field using Jquery and using a code like below:-

//retrieve values from hidden fields
var evename=document.getElementById("hdneventname").value;
var evenid=document.getElementById("hdneventid").value;
	 
//find the iframe loading the modal form
$("iframe").contents().find("#new_event").val(evenid);
$("iframe").contents().find("#new_event_name").val(evename);
$("iframe").contents().find("#new_event_entityname").val("new_event");

This I coded last month and It was working fine but for no reason it started breaking and client has come back with a bug. This script is added from CRM Portals by Going to Web form step->Edit->Options area. Error message in browser console as in below:

QTIC-error.png

Can someone suggest what could be the reason? The modal is opening on a button click and I have binded an event to populate a field which is present on the modal being loaded. The form having the button and modal both are on same portals and using https.

Thanks In Advance

Categories:
  • Rizwan Aarif Profile Picture
    480 on at
    RE: Dynamics CRM Portals - Cross origin frame issue

    Hi Arpit,

    Thanks,

    I am not using an external frame in my portals. both (page opening the modal/popup and modal popup itself) are part of same crm portals. I have also added these keys in Site Settings but does not seem to work. Any other work around /or way to populate a lookup which is on a modal form which opens on a button click (web form step)?

  • Suggested answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: Dynamics CRM Portals - Cross origin frame issue

    Hi Rizwan,

    You can't access or set value in <iframe> with different origin using JavaScript, It would be a huge security flaw if you could do it. For the same-origin policy browsers block scripts trying to access a frame with a different origin.

    If you were able to do this earlier then please check whether you have configured following site setting:

    Name : HTTP/Access-Control-Allow-Origin

    Value : Iframe URL or "*" to allow all domain URLs

    If you still having this issue, try use different logic. I don't think setting the value directly in IFrame controls would work.

    Regards

    Arpit

    http://arpitmscrmhunt.blogspot.com/

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

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Featured topics

Product updates

Dynamics 365 release plans