Sample HttpModule for CRM 2013 on premise.


Suppose we have to redirect user belonging to a specific group to some specific page, while they try to access CRM 2013.

For this we can implement an HttpModule

Sample code


public class Class1 : IHttpModule
{
public void Dispose()
{

}
public delegate void MyEventHandler(Object s, EventArgs e);
private MyEventHandler _eventHandler = null;

public event MyEventHandler MyEvent
{
add { _eventHandler += value; }
remove { _eventHandler -= value; }
}
public void Init(HttpApplication context)
{
context.AuthenticateRequest += new EventHandler(ContextOnAuthenticateRequest);
}

private void ContextOnAuthenticateRequest(object sender, EventArgs eventArgs)
{
HttpApplication app = sender as HttpApplication;
HttpContext context = app.Context;

// if the user belongs to adminsitrators role or reporting group
// redirect the user to bing.com
if (context.User.IsInRole(@"BUILTIN\Administrators") &&
context.User.IsInRole(@"LSS\ReportingGroup {0993772e-cfb6-47ba-8b88-2129bfc97f89}"))
{
app.Context.Response.Redirect("http://www.bing.com");
}

if (_eventHandler != null)
_eventHandler(this, null);
}
}

 

Put the dll in the bin of the CRMWeb

..\Microsoft Dynamics CRM\CRMWeb\bin

And register the http module in the web.config

(use sn –T MyModule.dll to get the public key token)

Moreover this can be implemented using URLRewrite as it runs before the authentication so we wont be able to get the username

http://www.iis.net/downloads/microsoft/url-rewrite

Hope it helps

 

 

How to – Use Pre-Filtering in Fetch XML based report in CRM 2013 online.


Hi,

We recently had a requirement to run a report on the form of a custom entity named incident.

It should show incident data and its related entity data i.e. contact and account.

Incident is having n: n relationship with Contact and Account here.

Here we will create three data sets one for showing the incident data and other two for the related entities.

Create a DataSet for Incident to fetch the incident record information (using Advanced Find View).

Make sure to set enableprefiltering as 1

This will create a report parameter in the report

Next we will create a DataSet for Contact entity which is n: n (many to many) related to Incident.

Download the fetch xml and add enableprefiletering attribute

Follow the same step for the DataSet for account entity related to Incident.

While uploading the select Display in value as “Forms for related record types” to run the report in the context of the form.

Report will start appearing in the Incident Form

Sample screenshot

 

Hope it helps

Advertisements