Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Add pop up window when creating a new lead or Opportunity

(1) ShareShare
ReportReport
Posted on by 815

Hello,

We have 3 business units and have a question.

When creating a NEW lead or Opportunity, first system should ask on which Business Unit to create. Should be Drop down windows or pop up window.

Note : First should ask to select BU then it should allow to create new lead or opportunity.

Kindly help !

*This post is locked for comments

  • Syed_Faisal Profile Picture
    815 on at
    RE: Add pop up window when creating a new lead or Opportunity

    Hi Mahender,

    Webresource created and it work fine inside network, outside (External) network it is not working, pl help.

    Here is the code :

    function SetBUField() {

       var BUName = window.parent.Xrm.Page.getAttribute("new_bu").getValue();

       if (BUName != null) {

           var req = new XMLHttpRequest();

           req.open("GET",

               Xrm.Page.context.getClientUrl() + "/api/data/v8.0/businessunits?$select=businessunitid,name",

               false);

           req.setRequestHeader("OData-MaxVersion", "4.0");

           req.setRequestHeader("OData-Version", "4.0");

           req.setRequestHeader("Accept", "application/json");

           req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

           req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");

           req.onreadystatechange = function () {

               if (this.readyState === 4) {

                   req.onreadystatechange = null;

                   if (this.status === 200) {

                       var results = JSON.parse(this.response);

                       for (var i = 0; i < results.value.length; i++) {

                           var businessunitid = results.value[i]["businessunitid"];

                           var name = results.value[i]["name"];

                           if (name == BUName) {

                               var lookUpValue = new Array();

                               lookUpValue[0] = new Object();

                               lookUpValue[0].id = businessunitid.replace('{', "").replace('}', "").toString();

                               lookUpValue[0].name = name.toString();

                               lookUpValue[0].entityType = "businessunit";

                               Xrm.Page.getAttribute("new_businessunitid").setValue(lookUpValue);

                           }

                       }

                   } else {

                       Xrm.Utility.alertDialog(this.statusText);

                   }

               }

           };

           req.send();

       }

    }

    //Function to Filter Market Segment

    MarketSegmentFilterSearch = function () {

           Xrm.Page.getControl("new_marketsegmentid").addPreSearch(function () {

    AddPreSearch();

           });

    }

    //Function to Filter Market Segment

    AddPreSearch = function () {

      var businessUnitId = Xrm.Page.getAttribute("new_businessunitid").getValue()[0].id;

    if(businessUnitId != null){

       var Filter = "<filter type='and'><condition attribute='new_businessunitid' operator='eq' uitype='businessunit' value='"+businessUnitId+"'/></filter>";

                   Xrm.Page.getControl("new_marketsegmentid").addCustomFilter(Filter, "new_marketsegment");

    }

    }

  • Syed_Faisal Profile Picture
    815 on at
    RE: Add pop up window when creating a new lead or Opportunity

    Hi Alex,

    I know but based on Business requirement, we changing the entire process.

  • Syed_Faisal Profile Picture
    815 on at
    RE: Add pop up window when creating a new lead or Opportunity

    Hi Mahender,

    Thanks for the kind help,

    Could you also please help by step to do it?

  • ashlega Profile Picture
    34,477 on at
    RE: Add pop up window when creating a new lead or Opportunity

    You might also add a "required" lookup field to the form - probably even faster that way..

    On a side note, leads and opportunities are not created "on a business unit" - they are assigned to a user/team, and, that's how they get related to a business unit (in other words, even if you have a lookup, for example, it won't change much.. It's all about which user/team the lead/opportunity will be assigned to)

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Add pop up window when creating a new lead or Opportunity

    Hi Syed,

    You can create html webresource and create a custom New button for lead and opportunity which will first open your html webresource and after that it will redirect you to lead and opportunity form accordingly. you can easily override new button like this way. You can see our post for your reference: http://himbap.com/blog/?p=1486 we have not used html webresource but you can do that can open web resource using Xrm.Utility msdn.microsoft.com/.../jj602956.aspx

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans