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)

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

I have the same question (0)
  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    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

  • ashlega Profile Picture
    34,477 on at

    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)

  • Syed_Faisal Profile Picture
    815 on at

    Hi Mahender,

    Thanks for the kind help,

    Could you also please help by step to do it?

  • Syed_Faisal Profile Picture
    815 on at

    Hi Alex,

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

  • Syed_Faisal Profile Picture
    815 on at

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

    }

    }

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