Open a contact screen as popup in MS CRM

Code (Javascript &Html)


<html><head>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/ -ui.js"></script>
<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
<link href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet">
</head><body style="border: 1px solid black; -ms-zoom: 1;">
<script type="text/javascript">

function Init () 
{
if (window.addEventListener) 
{  // all browsers except IE before version 9
window.addEventListener ("message", OnMessage, false);
}
else 
{
if (window.attachEvent) 
{   // IE before version 9
window.attachEvent("onmessage", OnMessage);
}
}
}
function OnMessage (event) 
{
       var message = event.data;
       OpenNewContact(message);
  }

function ChangeTab(tabId, tabIdToRemove)
{
    var divId=  tabId+"-1";
    $(".tabLink").removeClass("activeLink");
    $('#' + tabId).addClass("activeLink");
   $(".tabcontent").addClass("hide");
    $('#'+divId).removeClass("hide");        
    $('#' + tabId).removeClass("hide");

if(tabIdToRemove!='')
{
    $('#' + tabIdToRemove).addClass("hide");
}
}

function OpenNewContact(contactNumber) 
{
   var contactGUID="empty";
   var context=GetGlobalContext(); 
   var serverUrl = context.getClientUrl();
   var request = new XMLHttpRequest();
   var oDataSelect = serverUrl + "/xrmservices/2011/OrganizationData.svc";

request.open("GET", oDataSelect+"//ContactSet?$filter=MobilePhone%20eq%20'"+contactNumber+"'%20or%20Telephone1%20eq%20'"+contactNumber+"'", false);
request.setRequestHeader("Accept", "application/json,text/javascript, */*");
request.setRequestHeader("Content-Type", "application/json;charset=utf-8");
request.onreadystatechange = function () 
{
if (request.readyState == 4) 
{
if (request.status == 200) 

var response = JSON.parse(request.responseText).d.results;
                      alert('response :'+response);
                        $.each(response , function(i, resultObj){
                       contactGUID= resultObj.ContactId;
                      });                      
}
}
};
request.send();
var test=serverUrl +"/main.aspx?etc=2&id=%7b"+ contactGUID+"%7d&pagetype=entityrecord";
$("#myFrame2").attr('src', test);
ChangeTab('cont-2', '');
}

$(document).ready(function() {
    $(".tabLink").each(function(){
      $(this).click(function(){
        tabeId = $(this).attr('id');
        $(".tabLink").removeClass("activeLink");
        $(this).addClass("activeLink");
       $(".tabcontent").addClass("hide");
        $("#"+tabeId+"-1").removeClass("hide")   
        return false;  
      });
    });  
  });

Init();
</script>

<style type="text/css">
body {font-family:Verdana, Arial, Helvetica, sans-serif;}
.tab-box { 
  border-bottom: 1px solid #DDD;
  padding-bottom:5px;
}
.tab-box a {
  border:1px solid #DDD;
  color:#666666;
  padding: 5px 15px;
  text-decoration:none;
  background-color: #eee;
}
.tab-box a.activeLink { 
  background-color: #fff; 
  border-bottom: 0; 
  padding: 6px 15px;
}
.tabcontent { border: 1px solid #ddd; border-top: 0; padding: 5px;}
.hide { display: none;}

.small { color: #999; margin-top: 100px; border: 1px solid #EEE; padding: 5px; font-size: 9px; font-family:Verdana, Arial, Helvetica, sans-serif; }
</style>
 <br>
<div class="tab-box"> 
    <a class="tabLink activeLink" id="cont-1" href="javascript:;">App Tab</a> 
    <a class="tabLink hide " id="cont-2" href="javascript:;">Contact Tab</a> 
</div>

 <div tabindex="-2" class="tabcontent" id="cont-1-1"> 
<form id="form1" style="height: 100%;">
   <iframe width="1250" height="525" id="myFrame" src=""></iframe>
    <br><br>
    </form>
<div title="Contact Details" align="Right" id="hello"><p><font face="Georgia" size="4">
</font></p></div>
  </div>
  
  <div tabindex="-1" class="tabcontent hide" id="cont-2-1"> 
Test Contact Tab 
<br>
<form id="form2" style="height: 100%;">
    <iframe width="1000" height="1000" id="myFrame2" src="about:blank"></iframe>
    <br><br>
    </form>
  </div> 
</body></html>

கருத்துகள்

இந்த வலைப்பதிவில் உள்ள பிரபலமான இடுகைகள்