Description:
In this example we explain that how to create a custom Lookup control using HTML Web Resource in Dynamic CRM. Or how to create custom Lookup in Dynamic 365 using HTML Web resource and JavaScript. Or how to add Lookup field in HTML Web Resource in Dynamic CRM. Or how to display Lookup in HTML Web Resource using JavaScript in Dynamic CRM.
So here we demonstrate
that how to display Account Lookup using Web Resource in Dynamic CRM.we simply
display same account lookup as we have in dynamic CRM with all functionality
like search and add new Account using Web Resource.
<html>
<head>
<script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>
<script src="https://devmarch.crm8.dynamics.com//WebResources/msdyn_/Utils/jquery_1.7.1.min.js"></script>
<script type="text/javascript">
function
OpenLookup(objecttypecode) {
var
serverurl = "https://devmarch.crm8.dynamics.com";
var
DialogOptions = new Xrm.DialogOptions();
DialogOptions.width = 800;
DialogOptions.height = 600;
var url
= serverurl + "/_controls/lookup/lookupsingle.aspx?class=null&objecttypes="
+ objecttypecode + "&browse=0&ShowNewButton=0&ShowPropButton=1&DefaultType=0";
Xrm.Internal.openDialog(url,
DialogOptions, null, null,
CallbackFunction);
}
function
CallbackFunction(event) {
var
name = event.items[0].name;
var id
= event.items[0].id;
$('#txt_lookup_name')[0].value
= name;
$('#txt_lookup_id')[0].value
= id;
}
</script>
<style>
.enjoy-css
{
display:
block;
float:
left;
padding:2px 5px;
border:
1px solid #b7b7b7;
font:
normal 12px/normal
segoe ui;
}
.lookupImg
{
display:
block;
float:
left;
padding-top:2px;
border:
1px solid #b7b7b7;
}
.lookupAlignment
{
text-align:left;
vertical-align:middle;
}
span
{
font:
normal 16px/normal
segoe ui;
}
td {
font:
normal 14px/normal
segoe ui; width:200px;
}
</style>
</head>
<body>
<br>
<span>
Custom Lookup Control by - Kirit patel
</span>
<br><br><br><br>
<table>
<tbody><tr>
<td>Account </td>
<td class="lookupAlignment">
<input type="text" id="txt_lookup_name" class="enjoy-css">
<img id="img_lookup_search" src="https://devmarch.crm8.dynamics.com//WebResources/vj_search_normal.gif"
onclick="OpenLookup('1')"
class="lookupImg">
</td>
</tr>
<tr>
<td>Selected
Account Guid
</td>
<td>
<input type="text" id="txt_lookup_id" class="enjoy-css">
</td>
</tr>
</tbody></table>
<br>
</body></html>
0 comments:
Post a Comment