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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

GET Object FROM Html Web Resource - CRM ONLINE

(0) ShareShare
ReportReport
Posted on by 395

I try this:

Xrm.Page.ui.controls.get('WebResource_num1').getObject().contentWindow.document.getElementById('txt1').value="txt2";

but it not succeeded. I think that it because that i work with crm online.

Thanks
 

*This post is locked for comments

I have the same question (0)
  • Rajkumar Rajaraman Profile Picture
    on at

    Refer this thread:

    community.dynamics.com/.../153969

  • NAOMI314 Profile Picture
    395 on at

    thank you!

    but it dosen't help to crm online.

    thanks.

  • Verified answer
    NatrajY Profile Picture
    3,040 on at

    My suggestion would be shift the responsibility of setting a control in the IFrame, from the form script to a script in the actual IFrame itself. Once the IFrame DOM is ready, you should be able to either set the txt1 field to a static value, or grab the value from a field in the CRM Form. Eg.

    You could add something like this to the HTML webresource, that is loaded in the IFrame.

      document.addEventListener("DOMContentLoaded", function(e) {
    	document.getElementById('txt1').value = 'aaaa'; // static value
    	document.getElementById('txt1').value = parent.Xrm.Page.getAttribute('new_name').getValue(); //grab the current field value from the crm form
      });


  • Suggested answer
    Fubar Profile Picture
    2,761 on at

    The following will get a HTML Element from within a HTML Webresource:

    Xrm.Page.getControl("WebResource_<name_of_webresource_on_form>").getObject().contentWindow.window.document.getElementById("yourelementsid")

  • NAOMI314 Profile Picture
    395 on at

    thanks.

    I have done it but it didn't help :)

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    2,667 on at

    Hi,

    I think you can't directly access XRM so instead of this use window.parent.Xrm.

    So it should be like

    window.parent.Xrm.Page.getAttribute("CRMFieldSchemaName").getValue();

    Or,

    Xrm.Page.getControl(arg).getObject();

    Or see the below links,

    mahadeomatre.blogspot.in/.../disable-html-web-resource-control-from.html

    http://stackoverflow.com/questions/15536981/accessing-html-controls-inside-iframe

    Thanks

  • Fubar Profile Picture
    2,761 on at

    If you are within CRM and want to push something in to the web resource then you can access via Xrm

    If your script is within the Web resource you access as per usual JS

    If you are in one Web resource and need to update something in another Web resource then you need to get to Parent (see https://community.dynamics.com/crm/f/117/t/120221)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans