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)

Webresource using angularJs

(0) ShareShare
ReportReport
Posted on by 2

Hoi,

I have to migrate a 2011 application to dynamics 365. I have an issue with a AngularJS webresource tht gives an error on undefined element

In the account form, a webresource is hosted, that contains an angularJS form. The webresource itself is an html, which reference a controller, a module and a service javascript.

Goal is to update some field s of the account form, with the element chosen in the angular form.

The angular code looks like this:

$scope.ok = function () {var window_opener = window.dialogArguments;window_opener.FillAdresField(
    $scope.SelectedAdres.ves_adresid,
    null,
    $scope.SelectedAdres.ves_straat,
    $scope.SelectedAdres.ves_huisnummer); }

The FillAdresField is a function in a javascript library attached to the account form. It contains following code:

function FillAdresField(adresId, adresName, straat, huisnummer) {
    Xrm.Page.getAttribute("ves_adres1type").setSubmitMode("always");
    Xrm.Page.getAttribute("ves_adresid").setSubmitMode("always");
    Xrm.Page.getAttribute("address1_line1").setSubmitMode("always");
    Xrm.Page.getAttribute("address1_line2").setSubmitMode("always");
    Xrm.Page.getAttribute("address1_line3").setSubmitMode("always"); }

The Xrm.Page.Attributes seem not be known.

As I have no experience with this, can anyone point me in the right direction how to find a solution?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Radu Chiribelea Profile Picture
    6,667 on at

    Hi Birgit,

    Maybe you can try to reference the ClientGlobalContext.js.aspx inside your HTML web resources and then add there the logic of the FillAddressField method - as you will gain access to the Xrm.Page methods.

    Also, please check following articles for more information:
    msdn.microsoft.com/.../gg328541.aspx
    msdn.microsoft.com/.../gg309414.aspx
    community.dynamics.com/.../calling-custom-javascript-function-from-web-resource-on-parent-page
    dynamicscrm2011.wordpress.com/.../crm-2011-web-resource-part-1-using-html-web-resource
    dynamicscrm2011.wordpress.com/.../crm-2011-web-resource-part-2-how-to-use-clientglobalcontext-js-aspx

    Hope this helps!

    Radu

  • Verified answer
    JohnAnonymous Profile Picture
    5,241 on at

    If you want to fille the address field from javascript loaded in your iFrame webresource, you should prepend it with window.parent.

    So Xrm.Page.getAttribute("ves_adres1type").setSubmitMode("always");

    Would become

    window.parent.Xrm.Page.getAttribute("ves_adres1type").setSubmitMode("always");

    However, I read that you are calling a javascript function loaded on the form and not from your angular scripts. I don't know if that is wise to do.

  • Birgit RD Profile Picture
    2 on at

    After discussion with the colleague, decision was made to use a callback function iso calling a javascript function on the main form.

    Issue is solved.

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