Archive for the ‘MS Dynamics CRM’ Category

Microsoft Dynamics CRM 2013/2015 Custom Alerts and Popup Dialogs JavaScript Lightbox

August 24, 2015

sale.png

Overview

This JavaScript library for CRM 2013 and CRM 2015 allows us to create custom popup alerts in CRM forms and views.

CRM 2013 introduced light-boxes for most popups to make the UI look cleaner with less browser alerts and popups. However, these internal functions were not included in the SDK, so as developers we couldn’t access them for our custom code. Instead, we’ve been forced to use alertDialog and confirmDialog which under the hood just calls the browsers alert and confirm functions.

The main problems with this is that we cannot customize the buttons, and the alerts look ugly.

Using this library we can now hook into those internal functions allowing us to create our own seamless alerts and popups using custom buttons and custom callback functions for each button. We can also specify different types of icons to display in the alerts, instead of being forced to use the alert ‘exclamation mark’ or confirm ‘question mark’.

While technically unsupported, this code is manageable if it ever does break in future CRM releases, so it will be as simple as updating the solution files and everything will just work. In the event that the CRM Lightbox doesn’t work or isn’t supported (like in outlook), a modalDialog will be displayed.

How it Works

Download and install the unmanaged solution, then simply add a reference to mag_/js/alert.js wherever you want to use the custom alerts. This will work from forms, views, command bars, and pretty much anywhere in CRM that supports JavaScript.

Next simply call the Alert.show function. All other dependent web resources will be loaded automatically.

Parameters: Title (main message), Subtitle (smaller message), Buttons (array), Icon, Width (px), Height (px), CRM Base URL

All the parameters are technically optional. If no buttons are specified, a default ‘OK’ button with no callback will be added. If no icon is specified, then no icon will be displayed. If height is not specified, it will default to 225. If width is not specified it will default to 450. The URL only needs to be specified if the alert is being called from somewhere that doesn’t have Xrm.Page access (e.g. web resource).

Each button object in the buttons array needs to have a ‘label’ (text displayed on the button), and optionally a ‘callback’ (function called if the button is clicked).

The following icons are supported: “INFO”, “WARNING”, “ERROR”, “SUCCESS”, “QUESTION”.

Alert.show("Would you like to create a new Sale?", null,
    [{
        label: "Create Sale",
        callback: function () {
            Alert.show("Sale created successfully!", null, null, "SUCCESS", 500, 200);
        }
    },
    {
        label: "Not now"
    }], "QUESTION", 500, 200);

sale2.png

Download

Microsoft CRM 2013/2015 Custom Notifications in JavaScript

August 17, 2015

notify.png

Overview

This library gives developers the ability to create nice CRM notifications on forms and views, similar to the Xrm.Page.ui.setFormNotification SDK function, but better!

It gives us all the same functionality as the setFormNotification SDK function, but has the following additional features:

  • Allows you to add buttons and/or hyperlinks into the notification, with custom JavaScript triggered on click.
  • Supports additional icons, including SUCCESS, QUESTION, and LOADING
  • Supports custom HTML tags to be used manually in the notification message for greater flexibility
  • Ability to manually close a notification using the ‘X’ on the right hand side
  • Has smooth slide in and out transitions when adding and removing notifications
  • Ability to specify a duration after which that particular notification will disappear
  • Supports displaying notifications inside views from command bar buttons (only in web client – must specify duration)

notify_view.png

Add Notification

Adds or overwrites a notification on the custom notification bar. Note that this notification bar is separate to the CRM Notification bar.

Parameters: Message, Icon, Unique ID, Buttons (array), Duration (seconds – optional)

All parameters are technically optional, if there’s no icon specified the icon will be removed, if the unique ID is not specified, the ID will be null (and any new notifications with no ID will overwrite that one), the buttons are optional and will display after the message in the order they are added to the array, duration is optional, and if not specified the notification will only disappear if the user manually dismisses it or if other code removes it.

Supported Icon types are: “INFO”, “WARNING”, “ERROR”, “SUCCESS”, “QUESTION”, “LOADING”

Each button object in the array should have a ‘text’ to display on the button or hyperlink, a ‘callback’ function to call when the button or hyperlink is clicked, and optionally a ‘type’ of ‘link’ or ‘button’ (defaults to button if not specified)

Notify.add("Would you like to create a new <b>Sale</b>?", "QUESTION", "sale",
    [{
        type: "button",
        text: "Create Sale",
        callback: function () {
            Notify.add("Sale created successfully!", "SUCCESS", "sale", null, 3);
        }
    },
    {
        type: "link",
        text: "Not now",
        callback: function () {
            Notify.remove("sale");
        }
    }]);

notify2.png

Remove Notification

Removes one or all notifications from the custom notification bar. If an ID of a notification is passed to this function, that notification will be removed. If no ID is passed to this function, all notifications will be removed.

Parameters: Unique ID (optional)

// Remove a single notification
Notify.remove("sale");

 

// Remove all notifications
Notify.remove();

Download

Microsoft Dynamics CRM 2013/2015 Call Action, Workflow, or Dialog from JavaScript

August 10, 2015

Overview

This simple JavaScript library allows you to easily call workflows, dialogs, and actions in CRM from forms, views, web resources, or anywhere that supports JavaScript.

In the past if you’ve needed to call a workflow or action from JavaScript, you need to build a massive XML SOAP request making sure to pass in the correct attributes and conditions to get the request working.

This is tedious and messy, especially when there are many places you need to do this in a solution. It’s also not good if something breaks in the future and you need to go back and fix up all instances of where the code is being used.

For these reasons, I’ve created this library to simplify calling processes, and to make the code manageable going forward. But most of all, it’s so I don’t have to keep finding the correct way to build the SOAP requests!

For completeness, I’ve also included a function for calling dialogs, which simply pops open the specified dialog.

Call Workflow

Runs the specified workflow for a particular record asynchronously. Optionally, you can add callback functions which will fire when the workflow has been executed successfully or if it fails.

Parameters: Workflow ID/Guid, Record ID/Guid, Success Callback (function), Error Callback (function), CRM Base URL (not required on forms/views)

Usage:

Process.callWorkflow("4AB26754-3F2F-4B1D-9EC7-F8932331567A", 
    Xrm.Page.data.entity.getId(),
    function () {
        alert("Workflow executed successfully");
    },
    function () {
        alert("Error executing workflow");
    });

Call Action

Calls the specified action and returns the response from the action asynchronously. Useful when needing to run C# code from web resources or command bar buttons when only JavaScript is available.

Parameters: Action Unique Name, Input Parameters (array), Success Callback (function), Error Callback (function), CRM Base URL (not required on forms/views)

Each Input Parameter object should contain key, value, and type. Types are defined by Process.Type enum. EntityReference values should be an object containing id and entityType.

The Success Callback function should accept 1 argument which is an array of output parameters, each containing key, and value

Usage:

Process.callAction("mag_actionname",
    [{
        key: "Target",
        type: Process.Type.EntityReference,
        value: { id: Xrm.Page.data.entity.getId(), entityType: "lead" }
    }],
    function (params) {
        // Success
        for (var i = 0; i < params.length; i++) {
            alert(params[i].key + "=" + params[i].value);
        }
    },
    function (e) {
        // Error
        alert(e);
    }
);

Call Dialog

Opens the specified dialog for a particular record in a CRM light-box, or Modal Dialog if run from Outlook. Once the dialog is closed, the form or view is refreshed to display any new data changed by the dialog.

Parameters: Dialog ID/Guid, Entity Name, Record ID/Guid, CRM Base URL (not required on forms/views)

Usage:

Process.callDialog("C50B3473-F346-429F-8AC7-17CCB1CA45BC", "contact", 
    Xrm.Page.data.entity.getId(),         
    function () { 
        Xrm.Page.data.refresh(); 
    });

Download

Multiselect for Microsoft Dynamics CRM

August 7, 2015

Supported way for multiple value selection in Dynamics CRM.
Tested on Dynamics CRM 2013, CRM 2015.

Download

Microsoft Dynamics CRM 2011/2013/2015 (CRM Online) User Settings Tool

July 21, 2015

User Settings Tool is a tool for Microsoft dynamics CRM 2011/2013/2015 (CRM Online) that helps to update user personal settings in bulk. It includes the next tabs:
a) General.
b) Activity.
c) Email.
d) Privacy.
e) Languages.

Main Features:
1. It looks like CRM 2015 setting window.
2. Contains Display Names.
3. Shows user(users) settings on select.

UserSettingTool.jpg

Download

Microsoft Dynamics CRM 2015 Asynchronous Batch Process Solution

July 20, 2015

This project’s purpose is to supply an asynchronous batch processing solution for Microsoft Dynamics CRM 2015 in all deployment types.

The provided solution allows implementing business logic operations in a scheduled reoccurring manner.

Here are some of the business problems this solution can help solving:

– Check the due date for all open Cases once a day and set ‘Exceeding SLA’ indication if due date has passed
– Send monthly news letter automatically to target customers
– Update MSCRM Users details from Active Directory once a day
– Once a month, disqualify all leads that has no open activities

The solution implements the Asynchronous Batch Process Pattern which is described in the following posts:

Asynchronous Batch Process Pattern – Part 1
Asynchronous Batch Process Pattern – Part 2
Asynchronous Batch Process Pattern – Part 3

This version is described here:

Asynchronous Batch Process Solution Revisited – part 1

MS Dynamics CRM 2015 Manage auto-save

May 25, 2015

Auto-save helps people focus on their work without having to manage saving data in the form. Most people will appreciate not having to explicitly save data each time they update a record, but some organizations may have customizations that were designed expecting an explicit save. For these organizations there are options to manage how auto-save is applied.

How auto-save works

By default all main forms for Updated Entities will have auto-save enabled. After a record is created (initially saved), any changes made to a form will automatically be saved thirty seconds after the change is made. If no changes are made in the form, the automatic save won’t occur while the form is open. After a change is made the 30-second period before an auto-save begins again. The field that someone is currently editing isn’t included in an auto-save. If someone else has updated the same record while you’re editing it, those changes will be retrieved and displayed in the form when auto-save occurs.

With auto-save enabled, the save button only appears for the initial save of the record. After the record is created, the save button in the command bar isn’t shown, but you can see a Auto save button button in the lower right corner that will show if there are any unsaved changes. This control is also displayed if auto-save is disabled.

You can click this button to save the record and refresh data in the form immediately. When auto-save is enabled the record will be saved whenever you navigate away from a record or close a separate window displaying a record. There is no need for the Save & Close button that appears in forms for entities that aren’t updated.

Should you disable auto-save?

If you have plug-ins, workflows, or form scripts that execute when a record is saved, they’ll run each time auto-save occurs. This might lead to undesirable behaviors if these extensions weren’t designed to work with auto-save. Whether auto-save is enabled or not, plug-ins, workflows, and form scripts should be designed to look for specific changes, and shouldn’t execute indiscriminately for each save event.

If you have auditing configured for an entity, each save is treated like a separate update. If someone lingers on a form with unsaved changes for more than thirty seconds, you’ll see an additional entry only if they add more data after the auto-save is performed. If you have reports that depend on auditing data and treat each save as an individual “touch” of a record, you might see an increase in the frequency of touches. If you are using this approach, you should consider that individual user behaviors make it an unreliable metric with or without auto-save enabled.

Go to TechNet article

Upgrade Process from MS Dynamics CRM 2011 to MS Dynamics CRM 2015

May 18, 2015
  1. Create a brand new CRM 2013 environment. Since the CRM 2013 deployment is only temporary, the CRM 2013 deployment can be created as a virtual machine. CRM 2013 trial product key can be used, as this is a temporary setup.
  2. Create a brand new CRM 2015 Deployment.
  3. Take the Microsoft Dynamics CRM 2011 production deployment offline
  4. Export the organization database backup from the CRM 2011 environment.
  5. Restore the database in the CRM 2013 environment, using the sql server utility.
  6. Import the organization on the CRM 2013 using the deployment manager.
  7. Verify the upgraded CRM 2013 organization.
  8. Export the organization database backup from the CRM 2013 environment.
  9. Restore the database in the CRM 2015 environment, using the sql server utility.
  10. Import the organization on the CRM 2015 using the deployment manager.
  11. Verify the upgraded CRM 2015 organization.
  12. Import the solutions with refactored code.
  13. Perform validation to ensure the system is working as expected.

MS Dynamics CRM String Workflow Utilities

May 14, 2015

Custom workflow actions that deal with text strings in Dynamics CRM 2011, 2013, & 2015

Contains
Create Empty Spaces
EndsWith
Join
Length
PadLeft
PadRight
Regex Match
Regex Replace
Replace
StartsWith
Substring
ToLower
ToTitleCase
ToUpper
Trim
Word Count

Download

MS Dynamics CRM Numeric Workflow Utilities

May 13, 2015

Custom workflow actions that deal with numeric values in Dynamics CRM 2011, 2013, & 2015

Add
Average
Divide
Max
Min
Multiply
Random Number
Round
Subtract
ToDecimal
ToInteger
Truncate

Download


Follow

Get every new post delivered to your Inbox.

Join 31 other followers