Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Webresource using angularJs

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

  • Birgit RD Profile Picture
    Birgit RD 2 on at
    RE: Webresource using angularJs

    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.

  • Verified answer
    M.T. Eikelenboom Profile Picture
    M.T. Eikelenboom 5,241 on at
    RE: Webresource using angularJs

    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.

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: Webresource using angularJs

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans