Dynamics 365 CE Plugin Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers.

Today I faced an in an existing plugin which was working earlier. During investigation, I found that this is caused by the “HttpUtility.UrlEncode(clientSecret)” as shown in below code snippet image

HTTPUtilitySecurityError

I found 2 ways to fix this issue

  1. User “System.Net.WebUtility.UrlEncode()” instead of “System.Web.HttpUtility.UrlEncode()”.
  2. Use “System.Uri.EscapeDataString() ” instead of “System.Web.HttpUtility.UrlEncode()”. as suggested in the this blog post by Nishant Rana.

Thanks-

Plug-in Trace Logs only works in Sandbox mode in Dynamics 365 CE

Nishant Rana's Weblog

In my current Dynamics 365 implementation, we are back in the On-Premise world, after many years.

We thought of using the Plugin-Trace logs but was surprised to see that the Plug-Trace logs were not getting generated.

After doing the search realized that it only works for the plugin registered in the Sandbox mode.

https://docs.microsoft.com/pt-pt/powerapps/developer/common-data-service/logging-tracing

https://community.dynamics.com/crm/f/117/t/189346

So for time being, we registered in it Sandbox to get the trace.

Found the below article that has the workaround (unsupported)

http://blog.intocrm.net/how-to-write-plug-in-trace-logs-outside-the-sand-box/

Meanwhile, we can also Vote for the Idea

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Write-to-the-Plug-in-Trace-Log-from-assemblies-outside-SandBox/idi-p/222339

https://experience.dynamics.com/ideas/idea/?ideaid=abc7aceb-a8d9-e611-80c1-00155d460d59

Hope this helps..

View original post

Disable Export and Print button in Dynamics 365 CE (CRM) report viewer.

In one of my recent project, there was a requirement to disable/remove export button from report viewer (Only for certain set of users).

To achieve this, we had to remove below two permissions from all roles assigned to those users. You can remove one or both the permission to match your need.

  1. Export to Excel (to remove download option from report viewer)
  2. Print (to remove print option from report viewer)

Before removing permissions

After removing permissions

Thanks

References:

  1. https://www.powerobjects.com/2016/08/22/how-to-disable-exporting-or-printing-reports-in-dynamics-crm-2016/

Create XrmToolBox Plugin – Part 2: Debug XrmToolBox Plugin

In this blog, I will describe how to debug the XrmToolBox plugin project which we created in Part 1. If you have not read my first blog I recommend you read it first.

This is my second blog in the series of 4 blogs, below are the links to other blogs

  1. Create XrmToolBox Plugin – Part 1: Set-up Visual Studio and create a basic plugin
  2. Create XrmToolBox Plugin – Part 3: Package your plugin
  3. Create XrmToolBox Plugin – Part 4: Setup build definition release for CI and CD

Prerequisites:

  1. Visual Studio 2017.
  2. You have created the visual studio project and configured as mentioned in Part 1 of this series.

Step 1: Add post-build command to your VS project to create a Plugin folder and copy your plugin assemblies to this folder.

if $(ConfigurationName) == Debug (

IF NOT EXIST Plugins mkdir Plugins

move /Y SampleXrmToolBoxPlugin.dll Plugins

move /Y SampleXrmToolBoxPlugin.pdb Plugins

)

Step 2: Configure XrmtoolBox.exe to start on debugging by setting the XrmToolBox.exe path in “Start external program”. This exe can be found at “<<your plugin project location>>\bin\Debug\XrmToolBox.exe”. If you don’t see this exe in debug folder, just rebuild your plugin.

/overridepath:. – it will tell XrmToolBox.exe to look for the plugin in the debug folder of your project

/connection:”<<crm connection name>>” – the name of the CRM connection you have saved in XrmToolBox. It saves debugging time by automatically connecting to CRM instance.

/plugin:”<<plugin name>>” – the Name of your plugin as you have specified in “MyPlugin.cs” file

Step 3: Add XrmToolBox.exe.config file

You need to add this file to your project and set its property “Copy to Output Directory” to “Copy always”. This file can be found at

  1. “<<your plugin project location>>\packages\XrmToolBoxPackage.1.2018.6.25\lib\net462. If you don’t find config file here go to next step. This path will change as per XrmToolBox package version installed on your machine and .net version.
  2. Download XrmToolBox (same version as XrmToolBoxPackage )from here and copy its config file in your project.

Step 4: copy dependencies to XrmToolBox.exe.config

  1. Copy all missing dependencies from “app.config” file to “XrmToolBox.exe.config”.
  2. If you get any missing dependencies error when you debug your project, it needs to be added here.

Now you are all set to debug your project.

Hope it helps .

Reference: https://github.com/MscrmTools/XrmToolBox/wiki/Debug-your-plugins-during-development

Create XrmToolBox Plugin – Part 1: Set-up Visual Studio and create a basic plugin

Recently I created my first XrmToolBox plugin User Security Manager and successfully released this to the plugin store. I followed XrmToolBox for developers and the other resources available on the internet but creating a plugin was not so smooth for me, so I thought of writing my experiences and detailed step by step guide.

I will detail the entire process in 4 different blogs this is my first blog in this series.

  1. Create XrmToolBox Plugin – Part 2: Debug XrmToolBox Plugin
  2. Create XrmToolBox Plugin – Part 3: Package your plugin
  3. Create XrmToolBox Plugin – Part 4: Setup build definition release fo CI and CD

Prerequisites:

  1. Visual Studio 2017

Step 1: Download and install XrmToolBox Plugin Project Template: download VS 2017 project template and install on your dev machine.

Step 2: Open VS 2017 and go to File -> New -> Project…, it will open a new project window.

  1. Click on “Installed” (1) template and search for “Xrm” (2). You will see the above-installed plugin (3).
  2. Give a meaning full name to your plugin (4) and click OK(5).

  1. Click on “Trust” if you get following warning message.

Step 3:
Update Plugin Metadata open file “MyPlugin.cs” and update the following metadata details

  1. Name: Name of your plugin. It will appear in XrmToolBox plugin list and plugin store.
  2. Description: Short description of your plugin. It will appear in XrmToolBox plugin list and plugin store.
  3. SmallImageBase64: 32*32 logo of your plugin, to generate a base64 string of your plugin logo you can use this URL.
  4. BigImageBase64: 80*80 logo of your plugin, to generate a base64 string of your plugin logo you can use this URL.
  5. BackgroundColor: background color of your plugin
  6. PrimaryFontColor: Primary font color of your plugin
  7. SecondaryFontColor: Secondary font color of your plugin

Step 4: Build your plugin logic At this point you are all set to start building your logic into the plugin. You can create UI and add code logic but still, you cannot run/debug it. In my next blog I will talk about debugging, but before we go there let’s elaborate on the various components of this project, do’s and don’ts. (below is how default project structure will look like)

  1. MyPlugin.cs: This file contains all necessary metadata that defines your plugin, please make sure you have provided all the values in this file as described above.
  2. MyPluginControl.cs: all your plugin logic goes here or gets invoked from here.
    1. If your plugin logic is simple and does not requires much coding you can put everything in this class file (this is just my opinion).
    2. If your plugin logic is complex, and you are using some design pattern then this is the class where you will initialize your child components, controls.
    3. MyPluginControl_Load: You can put your initializing logic here. Like configuring the plugin as per the user settings, or resuming the plugin last used state etc.

    4. MyPluginControl_OnCloseTool: Your plugin close logic (if any) goes here.

    5. UpdateConnection: If you want to configure the behavior of your plugin on change of CRM connection, then you need to inject your logic here. For example, if you want to reload data from new CRM organization on XrmToolBox connection change, you can invoke that logic from this function.

    6. If your plugin needs multiple organization connections (one such example is if you are creating a plugin to move data from once CRM org to another CRM org), then you need to inherit “MultipleConnectionsPluginControlBase” class and implement “ConnectionDetailsUpdated” method. By default “MyPluginControl” class inherits “PluginControlBase” base call which provides access to only one Organization connection at a time.

      If you inherit “MultipleConnectionPluginControlBase” then you need to implement “ConnectionDetailsUpdate”

  3. Do’s and Don’ts:
    1. To ensure that Organization service is available when you execute your logic use “Service.Execute(<<your function name>>());” instead of invoking you function directly.

    1. Your plugin logic should be asynchronous, it should not block the tool itself. Use function “WorkAsync” and class “WorkAsyncInfo” to invoke your logic asynchronously, for details see here.

    1. Add proper logging to your plugin. “PluginControlBase” class provides 3 helper methods that you can use.

    1. Do not use early bound classes with your plugin.
    2. Your plugin should open with or with or without a connection available in XrmToolBox.

Hope It helps. In the next blog, I will explain how to debug your plugin in visual studio.

User Security Manager 1.2018.7.16 – Added features to manage Field Security Profile and view and export User security report.

I am excited to share that latest version of our XrmToolBox plugin “User Security Manager” is ready and available to download in XrmToolBox plugin store.

User Security Manager

We have implemented the following enhancement in the latest version

  1. Mange user’s field security profile, along with user security roles and teams in a single window.
  2. View user security report, sort and filter report for selected users.
  3. Download user security report (user to role mapping, users to teams mapping, users to fields security profile mapping), in csv format.

For more details of tool’s latest feature and user guide, please click here for complete user guide of this tool click here

We love to hear from you, please update/install it use it and share your feedback

My first XrmToolBox plugin for managing user’s security – User Security Manager

For past few weeks I have been thinking to add my bit to XrmToolBox, the most loved tool by me and the entire Dynamics 365 Community.

Here is my first plugin “User Security Manager”. Which I developed along with Nishant Rana.

User Security Manager

This tool will help in efficiently managing User’s security in Microsoft Dynamics 365 Customer Engagement. Below is the list of features it has

  • View all the security roles that assigned to the user either directly or through the team that the user is member of.
  • View all the Teams the selected user is part of.
  • With just a single click, remove all the security roles assigned to the user.
  • With just a single click, remove user from all the teams that user is part of.
  • Easily assign and unassign single or multiple security roles to the user.
  • Easily add or remove user from a single or multiple team.
  • Change the Business Unit of the user.

For more details of tool’s feature and user guide, please see this blog by Nishant Rana.

We love to hear from you please install it, use it, and share your feedback .

There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.

Issue: I was getting this error “There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing” when I was trying to resolve a case in dynamics CRM. Below is the detail error message.

<s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/”&gt;
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang=”en-US”>There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.</faultstring>
<detail>
<OrganizationServiceFault xmlns=”http://schemas.microsoft.com/xrm/2011/Contracts&#8221; xmlns:i=”http://www.w3.org/2001/XMLSchema-instance”&gt;
<ActivityId>47a272d8-8312-43c0-a360-ed042eeced84</ActivityId>
<ErrorCode>-2147220911</ErrorCode>
<ErrorDetails xmlns:a=”http://schemas.datacontract.org/2004/07/System.Collections.Generic”/&gt;
<Message>There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.</Message>
<Timestamp>2018-07-09T08:36:55.4146969Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil=”true”/>
<InnerFault>
<ActivityId>47a272d8-8312-43c0-a360-ed042eeced84</ActivityId>
<ErrorCode>-2147220911</ErrorCode>
<ErrorDetails xmlns:a=”http://schemas.datacontract.org/2004/07/System.Collections.Generic”/&gt;
<Message>There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.</Message>
<Timestamp>2018-07-09T08:36:55.4146969Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil=”true”/>
<InnerFault i:nil=”true”/>
<OriginalException i:nil=”true”/>
<TraceText i:nil=”true”/>
</InnerFault>
<OriginalException i:nil=”true”/>
<TraceText i:nil=”true”/>
</OrganizationServiceFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>

Root Cause: as evident from the error message there was some issue with some custom plugins on case close action. I was not having any custom plugin (or workflow) on this action but there was one from Microsoft (ActivityFeeds.Plugins.CaseClose). After disabling both steps of this plugin case started to resolve without any error.

Seems like there is some issue with the activityfeed plugin. As this plugin form MS worked fine till now so I started analysing why it is failing in my case. And finally, we came to now that it was happening because of empty customer name.

Fix: If customer (account/contact) name/full name is blank “(No name)” you will get this error. To resolve this issue you need to provide firstname/lastname/name field value on customer record.

 

PLAN PROPERLY before using Back and restore and Copy instances in Dynamics 365

Nishant Rana's Weblog

Recently we tried copying our DEV to one of the TEST instances. The idea was we were upgrading the click dimensions solution in our DEV so we wanted to make sure everything works fine after the upgrade and in case it didn’t we could then again copy it back from the TEST.

We had faced back and restore issues (instance failed) in the past so decided to go the Copy instance way this time.

However, we got the Instance Failed error on the TEST instance to which we were copying DEV to.

Interestingly the Edit, Reset, Delete etc option were still available and we could open the TEST instance (the original, as the copy of DEV had failed) without any issues.

Then we thought of giving a try again and started copy from DEV to TEST again. This time again it failed. And with no option of Edit, Reset, delete…

View original post 203 more words