Dynamics CRM 2015 Copy Price List

Having a large number of products under a price list means, there are large amount of price list items associating with them. Whenever a new price list is added to the CRM, price lists items are to be created even if the prices are same in that price list.

“Copy Price List” is to duplicate an existing price list with a new name, new start date and a new end date with its price lists items. If there are any changes to be done to any price list items users can do that manually while the other items remaining the same.

Source Code and the Managed Solution available in CODEPLEX

The solution is perfect when a system has large number of products with many price lists adding but price list items are getting rarely changes. This has packaged to work with CRM 2015 directly but using the source code that can be used with previous versions of CRM as well.

Go through the following the steps to install it and use it !

Continue reading “Dynamics CRM 2015 Copy Price List”

Advertisements

Debugging a Plug-in

Plugin is a .NET assembly that can be used to intercept events generated from the CRM system to perform a variety of actions. Some common plug-ins will perform a complicated update routine on CRM entities and\or attributes when it might be impractical to use Javascript or Workflow.

Not like in most of the other developments, in Plugins developers have to debug the CRM plugin code at the time of running the application. Developers writing the plugin code inside the plugin and some times the logic can be write in a seperate assembly and from the plugin code it can be invoked. When writing the whole logic inside the plugin is little complex to test the plugin logic by debugging the plugin as it executes from the application itself in a given event such as create an entity, update or delete.

There are two ways of debugging a CRM plugin as follows,
[1] Attaching the debugger to the w3p.exe process
[2] Forcing the add-in to call the debugger

Demonstration
A plugin has written targeting Account entities as follows and a step has registered to be fired on Account entity’s Create step.
Continue reading “Debugging a Plug-in”

DateTime in C#

Convert DateTime to a string with a relevent format


var usCultureInfo = new CultureInfo ("en-US", false);
var date = new DateTime (2012, 3, 22, 15, 6, 0);
date.ToString ("MM/dd/yy", usCultureInfo);

Binding a Dictionary to a Drop Down List

Binding data from a Dictionary is not so challenging as “Key” and “Value” pairs can be used for the drop down list properties. Following code samples show the results after assigning data source to the drop down list.

Before

Dictionary genderDictionary = new Dictionary();
genderDictionary.Add(1, "Male");
genderDictionary.Add(2, "Female");
genderDictionary.Add(3, "Transgender");

this.ddlGender.DataSource = genderDictionary;
this.ddlGender.DataBind();

Before Assign Key Value Pair

Continue reading “Binding a Dictionary to a Drop Down List”

Get the CRM server url from Silverlight [If the silverlight page is in a form]

private static String GetServerUrlFromCrmContext()
{
    try
    {
        // If the Silverlight is in a form, this will get the server url
        ScriptObject xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
        if (xrm != null)
        {
            ScriptObject page = (ScriptObject)xrm.GetProperty("Page");
            ScriptObject pageContext = (ScriptObject)page.GetProperty("context");

            String serverUrl = (String)pageContext.Invoke("getServerUrl");
            return serverUrl;
        }
        else
        {
            goto DevUrl;
        }
    }
    catch
    {
        goto DevUrl;
    }

    DevUrl:
    return "http://10.100.4.100:5555/MyOrganization";
}