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)

How to get the value present in HTML webresource through Javascript?

(0) ShareShare
ReportReport
Posted on by 90

Hi,

I want to show a popup to user to get some input. i have created a HTML webresource with 'input' element and used Alert.showWebresource() method to open a popup with input box. However, when i enter any value in that input box of HTML webresource, i'm not able to get it though javascript code. 

i have used document.getElementById but it failed.

Is there any way to get the value available in input box of HTML webresource?

*This post is locked for comments

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

    Hi,

    try to use  

    window.parent.document.getElementById()

  • Vinit Profile Picture
    90 on at

    i have tried it as well but i'm getting null value.

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi,

    look at this

    community.dynamics.com/.../190629

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi,

    Try window.parent.document.getElementById() instead of window.top.document.getElementById()

    https://stackoverflow.com/questions/7353847/javascript-error-window-top-document-getelementbyid-is-null-or-not-an-ob

  • deno43 Profile Picture
    115 on at

    You can do it by creating a callback function and pass it to window.showModalDialog() or window.open() where you open the webresource, get the data and pass it back to the callback function where you make use of the data.

    So you will have to open a dialog from the JS that is executing on the form...

  • Vinit Profile Picture
    90 on at

    Thanks Iswarya,

    I have tried both the ways, but it is still returning null value.

    Its not able to read the value present in HTML webresource.

  • Vinit Profile Picture
    90 on at

    Thanks ddelic,

    window.showModalDialog is unsupported and window.open is opening the window in new tab.

    But as per my requirement, I need to show a popup to get the input from user.

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi,

    try to use Prompt for getting user input

    function myFunction() {

       debugger;

           var txt;

           var person = prompt("Please enter your reason for 'Rejection':");

           if (person == null || person == "") {

               txt = "User cancelled the prompt.";

           } else {

               txt = person;

           }

           Xrm.Page.getAttribute("new_rejectreason").setValue(txt);

    }

  • deno43 Profile Picture
    115 on at

    I see you are using alert.js -> maybe you should consider using Alert.showDialogProcess method then and make use of callback function

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    How are you opening the HTML web resource?

    The is that there is not callback from the web resource, which is why you can't return the value.

    Did you try parent.Xrm.Page.getAttribute("new_field").setValue(textValue)?

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