Accessing custom aspx page from MS CRM 2011 and passing EntityID


Recently we got one request to show custom website page in CRM from left navigation in MS CRM 2011 based on the entity id. I am going to share the process so that it can help someone.

In our scenario we need to:

  • Create left navigation link for custom web page hosted on intranet website.
  • Pass current entity id to custom web page.
  • Custom page should be visible in associated view iframe.

As we need to pass entity id to custom web page, so we can create html web resource which will read entity id and will pass it to custom web page. Follow below steps to create html page:

  • Open default solution or you can create separate solution.
  • Navigate to Web Resources and select New to create new html web resource
  • Provide basic details for html web resource.
  • Open html editor and use below code

<html>

<head>

<script language=”javascript”>

function SetLeftNavigation() {

var WebPageURL=”http://CustomPageURL_Change&#8221;; //change custom page url

var EntityId = window.parent.Xrm.Page.data.entity.getId();//to access entityid from entity form

EntityId = EntityId.replace(‘{‘, ”).replace(‘}’, ”);

var iFramUrl = WebPageURL +”?id=”+ EntityId;

location.href = iFramUrl;

}

</script>

</head>

<body>

<script language=”javascript”>

SetLeftNavigation()

</script>

</body>

</html>

  • Save and publish your web resource.
  • Open your entity form, where we want to add left navigation.
  • Double click on left navigation section where you want to add custom link.
  • Navigate to Insert->Navigation Link to add new link.
  • Enter details like below

customlink

Name: Label that you want to give to custom link

Icon: you can create a custom image web resource and use it for icon

Web Resource: Select the html web resource we just created.

  • Save and publish your changes and test it.

Note: Please make sure to change quotation if you are copying code.

Advertisements

1 Comment

Filed under MS CRM 2011

One response to “Accessing custom aspx page from MS CRM 2011 and passing EntityID

  1. Pingback: Blog Posts of the Week (13th - 26th October 2013) - The South Asia MVP Blog - Site Home - TechNet Blogs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s