Search This Blog

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/

Lookup Control value set in CRM using Javascript

Lookup Control value set in CRM using Javascript

  var objPaymentModeValue = [{
        id: result[0].new_PaymentModeId.Id,
        name: result[0].new_PaymentModeId.Name,
        entityType: 'new_paymentmode'
    }];

 Xrm.Page.getAttribute("new_paymentmodeid").setValue(objPaymentModeValue);

Retrieve more than 5000 record in Query expression or Limit number of result record in query expression

 https://msdn.microsoft.com/en-us/library/gg327917.aspx


// Query using the paging cookie.
// Define the paging attributes.
// The number of records per page to retrieve.
int queryCount = 3;

// Initialize the page number.
int pageNumber = 1;

// Initialize the number of records.
int recordCount = 0;

// Define the condition expression for retrieving records.
ConditionExpression pagecondition = new ConditionExpression();
pagecondition.AttributeName = "parentaccountid";
pagecondition.Operator = ConditionOperator.Equal;
pagecondition.Values.Add(_parentAccountId);

// Define the order expression to retrieve the records.
OrderExpression order = new OrderExpression();
order.AttributeName = "name";
order.OrderType = OrderType.Ascending;

// Create the query expression and add condition.
QueryExpression pagequery = new QueryExpression();
pagequery.EntityName = "account";
pagequery.Criteria.AddCondition(pagecondition);
pagequery.Orders.Add(order);
pagequery.ColumnSet.AddColumns("name", "emailaddress1");                   

// Assign the pageinfo properties to the query expression.
pagequery.PageInfo = new PagingInfo();
pagequery.PageInfo.Count = queryCount;
pagequery.PageInfo.PageNumber = pageNumber;

// The current paging cookie. When retrieving the first page, 
// pagingCookie should be null.
pagequery.PageInfo.PagingCookie = null;
Console.WriteLine("Retrieving sample account records in pages...\n");
Console.WriteLine("#\tAccount Name\t\tEmail Address"); 

while (true)
{
    // Retrieve the page.
    EntityCollection results = _serviceProxy.RetrieveMultiple(pagequery);
    if (results.Entities != null)
    {
        // Retrieve all records from the result set.
        foreach (Account acct in results.Entities)
        {
            Console.WriteLine("{0}.\t{1}\t{2}", ++recordCount, acct.Name,
                               acct.EMailAddress1);
        }
    }

    // Check for more records, if it returns true.
    if (results.MoreRecords)
    {
        Console.WriteLine("\n****************\nPage number {0}\n****************", pagequery.PageInfo.PageNumber);
        Console.WriteLine("#\tAccount Name\t\tEmail Address");

        // Increment the page number to retrieve the next page.
        pagequery.PageInfo.PageNumber++;

        // Set the paging cookie to the paging cookie returned from current results.
        pagequery.PageInfo.PagingCookie = results.PagingCookie;
    }
    else
    {
        // If no more records are in the result nodes, exit the loop.
        break;
    }
}

CRM Form Load Performance

CRM Form Load Performance
Open the CRM on-premises and online in internet explorer.Click ctrl+shift+e

Send Mail when error occur in Scribe tool

Send Mail when error occur in Scribe tool

In scribe we have to alert recipents

Alert Recipients provide a means to notify users of alerts. Groups are formed from a stored list of individuals, each with an email address. Monitors and Integration Processes may be configured to notify a specific group and provide information on system status, data states, or business activity.


Adding alert recipient

Configure the email address

Create alert group and add recipients to group

Assigning a Recipient group in Monitor’s alert criteria






Append vs Append To

Append and Append To basically deal with the entities that are parties to a 1:N relationship or N:1 relationship.

Append: When an entity has the lookup of another entity on its form. It is important that the user have the “Append” privilege on this entity so that it can set the values for the lookups on this entity. For eg: Contact has the lookup of Account on its form so here the user needs to have the “Append” privilege to be able to set the parent account.

Append To: When an entity is available as a lookup on another entity form. It is important that the user have the “Append to” privilege on the entity that is referred to in the lookup so that it can set the values for the lookups of this entity on any other form. For eg: Account has the lookup of primary contact. So here the user needs to have the “Append To” privilege to be able to set the Primary Contact for the Account.

Report Server Folder Location

Native mode report server:
C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer
Sharepoint mode report server:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\WebServices\Reporting
Please look into below site:
https://msdn.microsoft.com/en-us/library/ms157273.aspx

CRM Plugin Message Export,ExportAll,ExportCompressed,ExportCompressedAll fire in plugin


1. Connect to SQL Server where CRM DB is located.
2. Open SQL Management Studio, open new query with context of your CRM DB (CRM_MSCRM or other name).
3. Execute following T-SQL Script:
Update SdkMessageFilter
Set IsCustomProcessingStepAllowed = 1
Where SdkMessageId in (Select distinct SdkMessageId From sdkmessage where name = 'ExportSolution')
4. Make IISReset.

5. Restart plugin registration tool - ExportSolution should be available for handling with plugins.

Wednesday, October 12, 2016

Different values with Date() in Chrome and IE

Different values with Date() in Chrome and IE

IE

Chrome



It is a bug in the ECMAScript 5.1 spec https://bugs.ecmascript.org/show_bug.cgi?id=112. From the comments on the bug, it appears that Chrome 35 implements what the spec says (literally), while IE 10 implements what the spec actually intended to say.
The bug relates to the same sentence in the spec mentioned in the question:
ECMA-262 edition 5.1 (p. 179): The value of an of absent time zone offset is "Z".
The draft version ECMAScript 6 (http://people.mozilla.org/~jorendorff/es6-draft.html) changes this sentence to:
If the time zone offset is absent, the date-time is interpreted as a local time.

Friday, September 30, 2016

Monday, September 26, 2016

Optionset name is already exist error occur while import solution in CRM

Error Description:
Optionset name is already exist error occur while import solution in CRM

Cause:
The schema name of the source and target environment must be same.

Target system Schema Name Destination system Schema Name
new_TestData new_testdata

Even though difference in the capitalisation, it won't import schema name must be same(name should be same in the  both environment)

Solutions:
 There are two solution.

  • Delete the column name in the destination and import the solution.

          Cons:
             If you delete the column in the destination, the data would loss.

  • Update the attribute table in the destination in the SQL as 

          "update Attribute set PhysicalName='new_TestData' where name ='new_testdata'"
          Cons:
            It works only in on-premise

Monday, September 12, 2016

Activity point type code in dynamics CRM

Activity point type code in dynamics CRM 

Value
Label
4201
Appointment
4202
Email
4204
Fax
4206
Case Resolution
4207
Letter
4208
Opportunity Close
4209
Order Close
4210
Phone Call
4211
Quote Close
4212
Task
4214
Service Activity
4251
Recurring Appointment
4401
Campaign Response
4402
Campaign Activity
4406
Bulk Operation

Monday, August 22, 2016

CRM Component name and thier corresponding Table Name

CRM Component name and thier corresponding Table Name:

NameTable Name
FormSystemForm
ViewSavedQuery
User viewUserQuery
Plugin Message(enable or disable)SdkMessageFilter
Accessing Webresource(enable or disable)Webresrouce- content column encoded as base64

Add new column/control in the phone call activity form in dynamics CRM

Add new column/control in the phone call activity form in dynamics CRM

When we click the "Add phone call" button in an account, It open the phone call with  minimum.


If you want to customize the form or add new column or control to form. Go to setting->Customization ->Entity->Phone Call->Forms->Phone call quick view.

When you open the phone quick view form is not an editable mode.



Solution:
Reason for form not able to editing "Customization" is set to false. To make it as "true".

 A simple trick but it would not work in CRM online.
Here's the SQL query to run against your Org_MSCRM database:
First, run this query to ensure that only 1 records are returned ( one for the Phone Call)
SELECT IsCustomizable, * FROM SystemForm WHERE Name = 'Quick Form' AND ObjectTypeCode IN (4210)

 I suggest taking a copy of the original FormXml from the SQL table before editing so that it can be reverted if something breaks, and a full database backup wouldn't hurt either.
At this point, you can save the results, including the FormXml column to file in case you need to revert any changes.

Then, to enable customisation of the forms:
UPDATE SystemForm SET IsCustomizable = 1 WHERE Name = 'Quick Form' AND ObjectTypeCode IN (4210)

I have tested in CRM 2015 and CRM 2016 it is working perfectly.

Friday, August 19, 2016

How Date time with time zone works in CRM

How Date time with time zone works in CRM


  • DateTime is saved in database as UTC time
  • DateTime queried directly from SQL table or base view returns UTC

  • DateTime in CRM UI is always shown based on user’s local time zone.



  • DateTime queried from filtered view returns users local time

Thursday, August 18, 2016

Change default base currency in CRM 2011

  1. Open Microsoft SQL Server Management Studio and connect to the SQL server hosting your CRM database.
  2. Find database with name [YourCompanyName]_MSCRM
  3. Backup that database!
  4. Open table [dbo].[TransactionCurrencyBase]
  5. The existing base currency is the first row. Ensure the target currency is there.
  6. Open table [dbo].[OrganizationBase] for edit. Find your organization there, most likely there will be just one row.
  7. Change CurrencySymbol, BaseISOCurrencyCode, BaseCurrencySymbol and BaseCurrencyId. The last field’s value you should take from TransactionCurrencyBase table, from the TransactionCurrencyId field.
That’s it. One thing you should bear in mind – if the conversion rate to base currency was used somewhere, the numbers may become incorrect. Like, if the sum was meant in base currency, but the base currency changed without recalculation.

Friday, August 12, 2016

The security timestamp is invalid because its creation time is in the future – Error CRM


 Error:
The security timestamp is invalid because its creation time is in the future – Error CRM

Reason:
  • There was difference in date and time settings between CRM Front end server and CRM DB Server.
  • There was difference in date and time settings between CRM server and plugin server.
  • There was difference in date and time setting between CRM server and AX connector or other integration tool.
Solution:
The Date and time must be same in the both server

Dynamics AX Connector with CRM adaptor settings

AX Connector:

CRM adapter:

CRM on premises:

CRM server time and dynamics adaptor running server time must be same. other wise you cannot connect crm adaptor.

In the CRM adaptor, we are going to use two user.

  • user1 (should not administrator in CRM)
  • user2(administrator in CRM as well as deployment administrator)




CRM on line:

Dynamics adaptor running server time must be correct time . other wise you cannot connect crm adaptor.

To connect CRM adaptor we are going to create two user.


  • user3@2016crm123.onmicrosoft.com(should not administrator in CRM)
  • user4@2016crm123.onmicrosoft.com

Note:
Once you create second user in the CRM online(office 365). Login the second user in CRM because at the time of first login of second user password need must be change.