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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Javascript to show alert with input box

(0) ShareShare
ReportReport
Posted on by

Hello All,

I want to show a popup to user with input field.

Example. If user clicks on 'UpdateRelationship' button available on 'Account' form, a pop up should open with input box which allows user to enter the name of the relationship. Once user enters the name and clicks Ok button, the name of relationship should be updated in the entity.

I was thinking about showmodaldialog or Xrm.Internal.openDialog, but these methods seems to be an unsupported. i also have tried alert.js library, but there is no provision to take the input from the user.

I'm using CRM 365 online version.

Please tell me how we can show a popup with input box to user.

*This post is locked for comments

  • Suggested answer
    Mahendar Pal Profile Picture
    on at
    RE: Javascript to show alert with input box

    Hi,

    You can create an html webresource and have your required field there after that you can use Xrm.Utility's openWebResource method to open it on button click .

    msdn.microsoft.com/.../jj602956.aspx

    Thanks

  • Suggested answer
    Aric Levin - MVP Profile Picture
    on at
    RE: Javascript to show alert with input box

    Take a look at alert.js

    github.com/.../alertjs

    This will probably be the best solution, and is widely used by CRM users.

    Hope this helps...

  • Community Member Profile Picture
    on at
    RE: Javascript to show alert with input box

    Following

  • Vinit Profile Picture
    on at
    RE: Javascript to show alert with input box

    Thanks Mahen for the response.

    I also tried Xrm.Utility.openWebResource but it is opening the webresource in new tab.

    I want it on the same page, same like the functionality of alert message.

    Is there any way to open this webresource in the same window?

  • Suggested answer
    RaviKashyap Profile Picture
    on at
    RE: Javascript to show alert with input box

    Hi Vinit,

    Did you try Alert.js? It has method to open web resource just like you wanted. Check the below links-

    github.com/.../Documentation

  • Vinit Profile Picture
    on at
    RE: Javascript to show alert with input box

    Thanks Ravi,

    I tried it, but unable to get the value from the webresource.

    could you please tell me the way to get the value from the input box once user entered in it?

  • Suggested answer
    Aric Levin - MVP Profile Picture
    on at
    RE: Javascript to show alert with input box

    To get a value back from a web resource you can use:

    Mscrm.Utilities.setReturnValue(returnValue);

    You will need to have the following reference in your web resource:

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

    If the alert.js does not work, you can use the following:

       var DialogOption = new Xrm.DialogOptions;

       DialogOption.width = 600; DialogOption.height = 450;

       Xrm.Internal.openDialog("/WebResources/new_myresource.html", DialogOption, null, null, myCallback);

    function myCallback(callbackValue)

    {

       if (callbackValue == "1")

       {

          // Your logic here

       }

    }

    Note that using Xrm.Internal is unsupported.

    Saying that it is still used by many, and hopefully Microsoft will add this functionality in a supported way (as they added the alert and confirm to the Xrm.Utility class).

    Hope this helps...

  • Paul NZ Profile Picture
    on at
    RE: Javascript to show alert with input box

    Hi Vinit,

    Check the documentation for these 2 functions which allows you to show a web resource, and then read the values from it:

    https://github.com/PaulNieuwelaar/alertjs/wiki/Documentation#alertshowwebresource

    https://github.com/PaulNieuwelaar/alertjs/wiki/Documentation#alertgetiframewindow

    Hope that helps

    Paul

  • Suggested answer
    Nithya Gopinath Profile Picture
    on at
    RE: Javascript to show alert with input box

    Hi Vinit,

    Please go through the following thread.

    nishantrana.me/.../using-xrm-internal-opendialog-as-an-alternate-to-showmodaldialog-in-crm

    Hope this helps.

  • Suggested answer
    Iswarya Profile Picture
    on at
    RE: Javascript to show alert with input box

    hi,

    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);

    }

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans