Thursday 29 June 2017

Open Entity Forms and HTML WebResource in Dynamics CRM using XRM.

Open Entity Form In ( create record mode)

Description:
In this example we explain that how to open entity forms and HTML Web Resource in Dynamics CRM.or open an Entity form in new window in dynamic CRM using XRM.or open an Entity form in Create or Edit Mode in dynamic CRM using XRM.or open entity form with URL in dynamic CRM using XRM.

Suppose you have requirement like in opportunity form user have rights to open new Lead form when click on button so that’s type of requirement XRM has provided functionality to open new entity form in create as well as edit mode using XRM.

So below is the code that will help you how to open new entity form like lead in new window.

To open a new Lead Record Form
window.parent.Xrm.Utility.openEntityForm(“lead”);

To open an existing Oppornity Record Form with edit mode

   var _accountId = Xrm.Page.data.entity.attributes.get("parentaccountid").getValue()[0].id;
var parameters = {};
   parameters["parentaccountid"] = _accountId;
var windowOptions = {
           openInNewWindow: true //this will define to open form in new window or current window.
       };
       //pop opp form with default values
       Xrm.Utility.openEntityForm("opportunity", null, parameters, windowOptions);

Below is the web resorce code that will create one button and when you click on this button it will open the new Lead Form.

<html><head>
<meta charset="utf-8">
<meta><meta><meta><meta><meta><meta>
 <meta><meta>
<script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<meta><meta><meta></head><body style="word-wrap: break-word;">
<meta><meta>
<table>
 <tbody><tr>
 <td><button onclick="myFunction();">Click here</button></td></tr>
 </tbody></table>
  <script type="text/javascript">
function myFunction() {
var options = { openInNewWindow: true };
window.parent.Xrm.Utility.openEntityForm("lead", null, null, options);
}
</script>

</body></html>
This entry was posted in :

0 comments:

Post a Comment