Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

alertjs popup window with input

Posted on by 2,397

Hi, can alertjs popup a dialog with input textbox?

*This post is locked for comments

  • Verified answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: alertjs popup window with input

    Try removing the parentheses after getType.

    Based on documentation this is the way to do it (after OK/type is clicked.

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: alertjs popup window with input

    now it is working, I have to remove the whole bracket.

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: alertjs popup window with input

    Hi, Aric,

    It still doesn't work until I make the change like the below, but it is not call back anymore, it directly execute the function "getType"

    function addAmount(){
    
     debugger;
    
     Alert.showWebResource("/Html/AddAmount",300, 200,"Please add amount for refund or decline",
    
       [
    
          new Alert.Button("type",getType()),
    
          new Alert.Button("Not now")
    
       ]);
    
    }


  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: alertjs popup window with input

    Remove  the function part from your getType call, or put the function inside:

    function addAmount(){

     debugger;

     Alert.showWebResource("/Html/AddAmount",300, 200,"Please add amount for refund or decline",

       [

          new Alert.Button("type",getType(),true, true,),

          new Alert.Button("Not now")

       ]);

    }

    Check if that fixes the issue.

    When you put a function ahead of the function name, the actual code has to go in there. If you want to call a function, you do not put the keyword function and curly braces.

    Hope this helps.

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: alertjs popup window with input

    it looks like it complains the button call back function "getType", once I remove that it works, but I do need the call back function.

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: alertjs popup window with input

    What error are you getting?

  • sdnd2000 Profile Picture
    sdnd2000 2,397 on at
    RE: alertjs popup window with input

    Hi, I am trying to get the values from the webresource, but I keep getting error, not sure what else I have missed.

    function addAmount(){
      debugger;
      Alert.showWebResource("/Html/AddAmount",300, 200,"Please add amount for refund or decline",
        [
           new Alert.Button("type",function (){getType()},true, true,),
           new Alert.Button("Not now")
        ]);
    }
    
    function getType(){
      debugger;
      var iFrameWindow = Alert.getIFrameWindow();
      var amount = iFrameWindow.document.getElementById("amount").value;
      var webtype = iFrameWindow.document.getElementById("type");
      alert(webtype.options[webtype.selectedIndex].text,amount);
    
    }
  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: alertjs popup window with input

    Hi,

      I don't think it can display a textbox, but it can display an iframe (maybe a web resource with a textbox then?)

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

      There is, also, an example of how to read return value from an input textbox in such an iframe

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: alertjs popup window with input

    Yes,

    You can do it by using the Alert.showWebResource.

    Create your own web resource with your own requirements, and call the above function.

    See: github.com/.../Documentation

    Hope this helps...

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans