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)

UCI + Set parent field from pop up webresource

(0) ShareShare
ReportReport
Posted on by 680

Hi Experts,

We are on Unified Client Interface.

On the Email form, I have a ribbon button that opens a web resource in a pop up using Xrm.Navigation.openWebResource. I have an optionset on this webresource and once the user clicks the OK button, i need to set this value to a specific field on the Email form. I am having a hard time accessing the field on the form from pop up Webresource. I have tried window.parent, window.opener and parent.Xrm and they were not able to access field on the form.

Also I tried adding ClientGlobalContext.js.aspx to the HTML Webresource but it is returning an error (Failed to load resource: the server responded with a status of 404 ())

   <script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script>

Any help is appreciated.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Create_5F00_PopupANDSave_5F00_Data.txt

    Hi LMP ,

    I have Created the pop up form on Account Entity through button click. When the Popup form open I placed some field on that form. after submitting form It will create Appointment as well as update some fields on the account Entity Form. I also provide full code through doc below Go through that It will help you.

    Please Mark as verified if answer helpful for you.

    Thanks

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi LMP,

    You could try window.opener.Xrm.Page.

    Below is my full web resource code:

     

      <div>

        <select id="list">

          <option value="1">Accounting</option>

          <option value="2">Agriculture and Non-petrol Natural Resource Extraction</option>

          <option value="3">Broadcasting Printing and Publishing</option>

          <option value="4">Brokers</option>

          <option value="5">Building Supply Retail</option>

        </select>

      </div>

      <div>

        <button onclick="test()">Set optionset value</button>

      </div>

     

    <script>

      function test() {

        debugger;

        document.getElementById("list");

        var val = list.value;

        setParentPageField(val);

      }

     

      function setParentPageField(val) {

        window.opener.Xrm.Page.getAttribute("industrycode").setValue(parseInt(val));

        console.log('ok');

      }

    </script>

     

    Result:

     7713.png

    However, the open web resource function on Ribbon button should be replaced with unsupported native JavaScript window.open instead of Xrm.Navigation.openWebResource

     

     var url = Xrm.Page.context.getClientUrl();

     

     var resourceName = 'new_plain';

     

     var resourcePath = url + '//WebResources/' + resourceName;

     

     window.open(resourcePath, '_blank', 'width=600,height=400,top=200');

     

    I'm not familiar about how CRM's open window function works in UCI, this supported function only works in Web client from my test; 

    while in UCI, the most significant thing is that the popup won't be center aligned, and the popup couldn't find its parent in window.opener via the supported function.

    So currently the solution would be working with unsupported native window.opener,

    and I have found no difference between this and openWebResource,

    we might need further investigation for CRM source JavaScript code if you would insist on supported way.

     

    Hope it helps.

    Best Regards,

    Leo

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