Search This Blog

Friday, January 6, 2017

Trace/Track CRM SQL Queries using SQL PROFILER

When we use to debug the CRM query using SQL profilers, the followings are important events.
Events
Name
Error And Warning
Blocked Process report
Exeception
TSQL
SQL:Batch completed
SQL:stmt completed
Store Procedure
RPC:Completed
SP:Completed
SP:stmt completed
Locks
Dead Lock graph
Query expression to track/trace SQL query events are Store procedure ->RPC Completed

Monday, January 2, 2017

Default timeout of Dynamics CRM logout After ADFS configuration

Increase Dynamics CRM Logout timout



  • Open the windows powershell in the adminsitrator mode.Type the below command

Get-ADFSRelyingPartyTrust -Name "relying_party"

Where you replace the “relying_party” with the name you identified in




  • In our case the command will be: 

Get-ADFSRelyingPartyTrust -Name “CRM IFD Relying Party“


  • The command to set the time you want to set for Auto Logout.

Set-ADFSRelyingPartyTrust -Targetname “CRM IFD Relying Party“ -TokenLifetime 720

Note: The 720 is time in minutes. 12 Hours in this case. You can change the value up and down as liked

Thanks to https://www.interactivewebs.com/blog/index.php/server-tips/crm-2015-extend-auto-logout-time-in-ifd/

Thursday, December 22, 2016

Plugin Message in Dynamics CRM

Plugin Message in Dynamics CRM




Message

Description

Create

This message will trigger when-ever primary entity record is created

Update

This message will trigger when-ever primary entity record is updated

Retrieve

This message will trigger when-ever primary entity record is retrieve( entity form open).

Eg: In the Active account grid, double click any one of the record this message will trigger.

Retrieve Multiple

This message will trigger when-ever primary entity records are viewed from grid.

Publish All customization

This message will trigger when-ever you click "PublishAll"

Publish

This message will trigger when-ever you click "Publish" on webresource and entity form.

Grant Access

This message will trigger when-ever record is shared 

Revoke Access

This message will trigger when-ever record is unshared

AddMember
This message will trigger and primary entity is "list" when-ever add member in the marketing  list through UI.

RemoveMember

This message will trigger and primary entity is "list"  
when-ever remove/delete member in the marketing
  list through UI.

AddListMember

This message will trigger and primary entity is "list" when-ever add member in the marketing  list through AddListMembersListRequest class(console application.

AddItem

This message will trigger whenever you add marketing list in the campaign activity
Remove Item

This message will trigger whenever you add marketing list in the campaign activity







Thursday, December 15, 2016

Convert OptionSet to MultiSelect checkboxes in CRM


  • Create two fields to store optionset value and text
  • Create html webresource with below source code.

<html>
<head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            ConvertDropDownToCheckBox();
        });

        //Coverts option list to checkbox
        function ConvertDropDownToCheckBox() {

            var _optionSet = parent.Xrm.Page.getAttribute("new_optionSet").getOptions();
            var _optionSetValue = parent.Xrm.Page.getAttribute("address1_line1").getValue();

            $(_optionSet).each(function (i, e) {

                var _text = $(this)[0].text;
                var _value = $(this)[0].value;
                var _isChecked = false;
                if (_text !== '') {
                    if (_optionSetValue !== null && _optionSetValue.indexOf(_value) !== -1)
                        _isChecked = true;

                    var _checkbox = "<input type='checkbox' name='" + _value + "'/>";
                    $(_checkbox)
                        .attr("value", _value)
                        .attr("checked", _isChecked)
                        .attr("id", "id" + _value)
                        .click(function () {

                            //To Set Picklist Select Values
                            var selectedOption = parent.Xrm.Page.getAttribute("address1_line1").getValue();
                            if (this.checked) {
                                if (selectedOption === null)
                                    selectedOption = _value;
                                else {
                                    var temp = selectedOption.indexOf(",") !== -1 ? selectedOption.split(',') : selectedOption.split(' ');
                                    temp.push(_value);
                                    selectedOption = temp.join();
                                }
                            }
                            else {
                                if (selectedOption.indexOf(_value) !== -1) {
                                    var temp = selectedOption.indexOf(",") !== -1 ? selectedOption.split(',') : selectedOption.split(' ');
                                    temp = removeArrayElement(temp, _value);
                                    selectedOption = temp.join();
                                }
                                else
                                    selectedOption = selectedOption.replace(_value, "");
                            }
                            parent.Xrm.Page.getAttribute("address1_line1").setValue(selectedOption.toString());


                            //To Set Picklist Select Text
                            var _selectedText = parent.Xrm.Page.getAttribute("address1_line2").getValue();
                            if (this.checked) {
                                if (_selectedText === null)
                                    _selectedText = _text;
                                else {
                                    var temp = _selectedText.indexOf(',') !== -1 ? _selectedText.split(',') : _selectedText.split(' ');
                                    temp.push(_text);
                                    _selectedText = temp.join();
                                }
                            }
                            else {
                                if (_selectedText.indexOf(_text) != -1) {
                                    var temp = _selectedText.indexOf(',') !== -1 ? _selectedText.split(',') : _selectedText.split(' ');
                                    temp = removeArrayElement(temp, _text);
                                    _selectedText = temp.join();
                                }
                                else
                                    _selectedText = _selectedText.replace(_text, "");
                            }
                            parent.Xrm.Page.getAttribute("address1_line2").setValue(_selectedText);

                        }).appendTo(checkBoxContainer);
                }


                //add label to the checkbox
                $("<label for='" + _value + "'>" + _text + "</label>").appendTo(checkBoxContainer);
            });
        }


        function removeArrayElement(arr) {
            var what, a = arguments, L = a.length, ax;
            while (L > 1 && arr.length) {
                what = a[--L];
                while ((ax = arr.indexOf(what.toString())) != -1) {
                    arr.splice(ax, 1);
                }
            }
            return arr;
        }

    </script>
</head>
<body>

    <div id="checkBoxContainer">
    </div>

</body>
</html>

Please refer
https://community.dynamics.com/crm/f/117/t/211615

Show only date in SSES executiondatetime

In the SSRS report Expression column
Format(Globals!ExecutionTime, "MM/dd/YYYY")

Pass parameters to Plugin Using Secure or Unsecure Configuration Using Plugin Registration Tool in MS CRM

Pass parameters to Plugin Using Secure or Unsecure Configuration to Plugin:
When you start developing plugins, you often need an input parameter or a configuration for the plugin execution which can be easily updated without having to re-compile and/or re-register the plugin.
For example , i want to read some of the data which may change every time. Rather than creating the custom entity to read the Configuration kind of thing better to use this method to read the Parameters.
Use the plugin step “Configuration”
When you register a plugin step, there is a field where you can specify some configuration parameters for the plugin execution as below:Image
Then in the Constructor of your plugin class you will get the configuration value which you can use later in the Execute method:
Image2

In the Quickwatch you can watch the total configuration as follows:
Image1

have a glance below for plugin code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using System.Xml;
namespace ReadPluginConfgInPlugins
{
public class PluginConfg : IPlugin
{
private readonly string _unsecureString;
private readonly string _secureString;
public PluginConfg(string unsecureString, string secureString)
{
if (String.IsNullOrWhiteSpace(unsecureString) || String.IsNullOrWhiteSpace(secureString))
{
try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(unsecureString);
Guid DefaultQueueGuid = PluginConfiguration.GetConfigDataGuid(doc, “Contact Guid”);
string ContactFullName = PluginConfiguration.GetConfigDataString(doc, “Full Name”);
int MobileNumber = PluginConfiguration.GetConfigDataInt(doc, “Mobile Number”);
bool Gender = PluginConfiguration.GetConfigDataBool(doc, “Gender 0 refer to Male”);
}
catch (Exception ex)
{
throw new Exception(“SoapException” + ex.Message + “########” + ex.StackTrace + “$$$$Inner Exception” + ex.InnerException);
}
}
}
public void Execute(IServiceProvider serviceProvider)
{
//Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
// For this sample, execute the plug-in code only while the client is online.
tracingService.Trace(“AdvancedPlugin: Verifying the client is not offline.”);
if (context.IsExecutingOffline || context.IsOfflinePlayback)
return;
// The InputParameters collection contains all the data passed
// in the message request.
if (context.InputParameters.Contains(“Target”) &&
context.InputParameters[“Target”] is Entity)
{
Entity entity = (Entity)context.InputParameters[“Target”];
}
}
}
}
For this approach also have a Pros and Cons.
PROS:
  • The step configuration is solution-aware so it will be automatically transported with the plugin step.
CONS:
  • You need to use the plugin registration tool or another application to update the step configuration.
  • The configuration is step-specific so you have to provide it and/or update it for every step even if the value is the same for all the steps (the configuration is on each step instead of the assembly or plugin type).
  • the configuration is just an attribute of the plugin step so you cannot control privileges on the configuration independently from privileges on plugin step entity.
*. Use the plugin step “Secure Configuration”
This is similar to the step Configuration except that the configuration data is stored in a separate entity which can be secured.
PROS:
  • The configuration data can be secured as any other entity using the CRM security model. This is useful when the configuration contains sensitive information such as passwords.
CONS:
  • Secure configuration is not solution aware so you will need to configure it for each environment.
  • You need to use the plugin registration tool or another application to update the step configuration.
  • The configuration is step-specific so you have to provide it and/or update it for every step even if the value is the same for all the steps (the configuration is on each step instead of the assembly or plugin type).
*. Use a Web Resource
You can store configuration information in web resources, for example you might have some XML configuration stored in a web resource and have your plugin read the web resource each time it executes.
PROS:
  • Web resources are solution aware and the GUID is preserved across environments so you can hardcode the web resource GUID in your plugin code. You can transport the web resource and the plugin in the same solution.
  • Can be easily updated using the CRM UI.
CONS:
  • You cannot secure the configuration since it depends on the web resource access privileges and most users will need at least read access to web resources.
Hope this may help you.

Thanks to the below site
https://srmscrm.wordpress.com/category/ms-crm-2011/ms-crm-2011-plugins/