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)

dropdown list on form load

(0) ShareShare
ReportReport
Posted on by

Hi,

I am looking for approaches on how to implement this.

I want to show a popup with a dropdown list which user can choose a selection on form load. What is the best way of doing this?

Thanks.

*This post is locked for comments

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

    Please try to create an html webresource (with dropdown) and try to open it on formload using javascript.

    please try to use 

    Xrm.Utility.openWebResource(webResourceName,webResourceData,width, height)

    for more info please see the link below

    https://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenWebResource

    thanks

    Anil

  • Suggested answer
    Sean Michel Profile Picture
    340 on at

    Hi Udemi,

    What is the end-goal of this requirement?  Would you hide/show different fields/tabs based on the User input? If so you may consider doing the following, which would negate the need for a custom web resource drop-down:

    1. Hide all tabs on form by default

    2. Detect FormType Xrm.Page.ui.getFormType();

    3. Where FormType = 1 (create) display the tab that contains only your CRM out of box option-set - make it required to save the record.

    4. Then, call a JavaScript function onChange of your option-set to show the appropriate tabs once your option-set contains data.

    Otherwise, please let me know a little more detail surrounding your requirement.

    Thanks!

    Sean

  • Community Member Profile Picture
    on at

    Thanks Sean..

    My requirement is.. we have a system where user enters incidents for a particular team that he is a part of. A user may belong to multiple teams and he would enter incidents for a particular team.

    So before creating any record we would like to give him an option to choose for which team he wants to create the incident for. And once he selects the team, his selected team name will need to be populated in a look up field.

    Thanks again for responding to this.

  • Community Member Profile Picture
    on at

    Hi Anil,

    I tried your suggestion and everything works out well but the html dropdown does not show like a pop up instead it opens like a new window and has a dropdown list in it. In IE, it is even worse.. a new tab gets opened with just the dropdown in it and the whole screen is blank. I even tried jquery to create the dropdown modal dialog and it is still the same. I am thinking of showing a pop up box with dropdown in it but everything I tried opens a new window with just the dropdown.

    Here is my script for creating dropdown:

    <html><head>
     <title></title>
          <link href="../../../Scripts/css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css">
        <script src="../../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="../../../Scripts/jquery-ui-1.8.16.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                // this function is triggered as soon as something changes in the form
                $("select[name='inptPAN']").change(function () {
                    //console.log('found change');
                  selectDialog('Pan','You had selected, Text: '+ $(':selected',this).text()+' And Value : '+$(this).val());
                });
    
                function selectDialog(title, text) {
                    return $('<div></div>').append(text)
                .dialog({
                    resizable: true,
                    modal: true,
                    buttons: {
                        "OK": function () {
                            $(this).dialog("close");
                        }
                    }
                });
                }
            });
        </script><meta><meta charset="utf-8"><meta><meta></head>
    <body style="width: 500px; height: 500px; -ms-word-wrap: break-word;"> 
    <div id="selectPopup">
        <form name="test" style="width: 100px;">
            <select name="inptPAN" id="inptPAN">
                <option value="1">item 1</option>
                <option value="2">item 2</option>
                <option value="3">item 3</option>
                <option value="4">item 4</option>
                <option value="5">item 5</option>
                <option value="6">item 6</option>
            </select>
      </form>
        </div>
     </body></html>

    Thanks.

  • anilambadan Profile Picture
    1,160 on at

    Hi

    If your requirement is like you explained to Sean, why cant you create an optionset on incident form itself and while users selecting the team from the optionset, try to findout the team lookup based on the selection using javascript?

    thanks

    Anil

  • Suggested answer
    Sean Michel Profile Picture
    340 on at

    Hi Udemi,

    Thanks for the explanation! I would really suggest not using a web-resource in this scenario, given your requirement.

    If you'd like to hide all the other fields and force the user to enter the appropriate Team, I'd suggest using some simple Hide/Show JavaScript (msdn.microsoft.com/.../gg328067.aspx) to hide the other tabs while form = create. Then, you could use business rule/javascript to make your look-up to the Team entity required.

    I'd just use a direct look-up to the Team itself, cutting out the need for any drop-down.

    This would be the route I'd suggest, over some modal/pop-up web resource.

    Let me know with any questions!

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