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:
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
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)?
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