Month: April 2018

Count the number of related child records using a Rollup field

Its going to be a very simple and basic blog where i will show you how you can count number of related records for e.g.

  1. number of cases related to account/contact
  2. number of opportunities related to account/contact
  3. number of active quotes for a contact

this list can go one. In short wherever you have 1:N relationship ; you should be able to perform this operation. it will show something like below :

1

 

  1. To do this create a field on parent record – select the name and select the data type as “whole number” and  field type as “RollUp”  :2
  2. after doing this as soon as you click on “edit” – it saves the field and give you an editor , just like a business rule select the cases(customer) as a related entity.
  3. you can define condition below that for e.g where status of the case  = active or where cases owner is a particular user.
  4. finally in the Aggregation select “COUNT” and in the next field it will show you just one option as case.
    3
  5. finally save the editor and put this field on the form. When you open the form after the publishing all customization , you might see this as 0 at first place its because rollup fields are nothing but system jobs in the background which runs at particular time ( 12 hours to be specific) but you can always force it by clicking to that refresh button in the field :
    5

once all done you will have this field showing you the related records count.

 

i hope this helps!

Know When/Who Imported the Solution to Dynamics CRM

I get this question very often – “how do we know when and who imported the solution into CRM?”

Whilst there are so many method of knowing it for e.g looking into database or checking in the XML, there is tool which can be used. Available as a plugin for XRM tool box. It shows something like below:

solutionhistory

Download the XRMToolBox from here : https://www.xrmtoolbox.com/ and extract to a folder. Run the application & follow below steps:

  1. from the main header options , click on tools> plugin store:
    pluginstore
  2. on the next screen search for “Solution History” and select the plugin and click on “Install”:
    installation
  3. post this close this screenshot and open the tool from main xrmtoolbox navigatation.
    as soon as you open it – it will give you all the available solutions and as you select the solution it gives the information you need ( showed in the screenshot 1)

 

i hope this helps!

Unified Service Desk – Blog 1 – Introduction

Hi Guys,

This is going to be a series of blogs about unified service desk where I will be taking you through all the configuration regarding USD. But first lets understand what is USD and why it is becoming an important add-on for Microsoft Dynamics CRM.

Unified Service Desk, which is built using the User Interface Integration (UII) framework, is designed as a series of adapters and modules that facilitate management of Dynamics 365 UI elements (such as pages and dialogs), automatic loading of related records, agent scripting, a configurable toolbar, and so on.

IC835510

                                                            [Picture source : Microsoft Technet]

How to get started?

  1. Create your trial of dynamics crm account or its okay if you have your dev environment. https://trials.dynamics.com/
  2. Download USD package deployer & Unfiied service desk application from here :
    https://www.microsoft.com/en-us/download/details.aspx?id=56555&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1
    Capture
  3. first one is your package deployer that will help you to install the base solutions in your dynamics crm to get started with USD and second & third options is your actual unified service desk applications depending on your system processor type.
  4. Run the package deployer setup and connect to your dynamic crm and select first solution click next and let it install the solution to your dynamics crm, same way run the second the installation. you can go through details of these solution and what they contain in technet/msdn or the package deployer itself:
    solutions
  5. once you have installed these – you will them in your dynamics crm ( navigate to Settings>solution :
    solutionincrm
  6. Now you are all set to login to your dynamics CRM application using USD, run the main setup and install it. Connect to your dynamics crm and this is what you see initially :
    usdinitialscreen.JPG

To understand the panel types available in USD , please go through : https://msdn.microsoft.com/en-in/library/dn865006.aspx

 

So, now that we are ready with our CRM and USD, we can jump into configuration of this instance. In my next blog-2 . I will show how to create a simple navigation button (toolbar) in USD.

 

I hope this helps!

 

How to Create Auto- Number Fields

Requirement for creating an auto number field is very common & achieving them used to be very difficult or unsupported(using third party tools) . Now with Dynamics CRM 365, you can create an auto-number attribute very easily.

At this moment its not available in the UI , you will have to do it programmatically but its  very less and easy code.

following the format which can be achieved :

AutoNumberFormat value Example value
CAR-{SEQNUM:3}-{RANDSTRING:6} CAR-123-AB7LSF
CNR-{RANDSTRING:4}-{SEQNUM:4} CNR-WXYZ-1000
{SEQNUM:6}-#-{RANDSTRING:3} 123456-#-R3V
KA-{SEQNUM:4} KA-0001
{SEQNUM:10} 1234567890
QUO-{SEQNUM:3}#{RANDSTRING:3}#{RANDSTRING:5} QUO-123#ABC#PQ2ST
QUO-{SEQNUM:7}{RANDSTRING:5} QUO-0001000P9G3R
CAS-{SEQNUM:6}-{RANDSTRING:6}-{DATETIMEUTC:yyyyMMddhhmmss} CAS-002000-S1P0H0-20170913091544
CAS-{SEQNUM:6}-{DATETIMEUTC:yyyyMMddhh}-{RANDSTRING:6} CAS-002002-2017091309-HTZOUR
CAS-{SEQNUM:6}-{DATETIMEUTC:yyyyMM}-{RANDSTRING:6}-{DATETIMEUTC:hhmmss} CAS-002000-201709-Z8M2Z6-110901

lets see how this can be done , in this example i am giving my custom organization entity a serial auto numbered field. you can do this both by C# code or Webapi :

C#

CreateAttributeRequest widgetSerialNumberAttributeRequest = new CreateAttributeRequest

            {
             EntityName = "new_organization",
             Attribute = new StringAttributeMetadata
                {

                    //Define the format of the attribute

                    AutoNumberFormat = "ORG-{SEQNUM:3}-{RANDSTRING:6} ",
                    LogicalName = "new_serialnumber",
                    SchemaName = "new_SerialNumber",
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
                    MaxLength = 100, // The MaxLength defined for the string attribute must be greater than the length of the AutoNumberFormat value, that is, it should be able to fit in the generated value.
                    DisplayName = new Microsoft.Xrm.Sdk.Label("Serial Number", 1033),
                    Description = new Microsoft.Xrm.Sdk.Label("Serial Number of the widget.", 1033)
                }

            };
            crmService.Execute(widgetSerialNumberAttributeRequest);

As you can see in my request i have given AutoNumberFormat  as ORG-{SEQNUM:3}-{RANDSTRING:6} from the List.

in case you need the full code:

using System;

using System.ServiceModel;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Metadata;

using Microsoft.Xrm.Sdk.Messages;



amespace Microsoft.Crm.Sdk.Samples

    {

        public class FollowupPlugin : IPlugin

        {
            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));
            

            CreateAttributeRequest widgetSerialNumberAttributeRequest = new CreateAttributeRequest
            {

                EntityName = "new_organization",
                Attribute = new StringAttributeMetadata

                {
                    //Define the format of the attribute
                    AutoNumberFormat = "ORG-{SEQNUM:3}-{RANDSTRING:6}  ",
                    LogicalName = "new_serialnumber",
                    SchemaName = "new_SerialNumber",
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
                    MaxLength = 100, // The MaxLength defined for the string attribute must be greater than the length of the AutoNumberFormat value, that is, it should be able to fit in the generated value.
                    DisplayName = new Microsoft.Xrm.Sdk.Label("Serial Number", 1033),
                    Description = new Microsoft.Xrm.Sdk.Label("Serial Number of the widget.", 1033)
                }
            };

            crmService.Execute(widgetSerialNumberAttributeRequest);
       }

    }

WebAPI

{
 "AttributeType": "String",
 "AttributeTypeName": {
  "Value": "StringType"
 },

 "Description": {
  "@odata.type": "Microsoft.Dynamics.CRM.Label",
  "LocalizedLabels": [
   {
   "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
    "Label": "Serial Number of the widget.",
   "LanguageCode": 1033
   }
  ]
 },

 "DisplayName": {
  "@odata.type": "Microsoft.Dynamics.CRM.Label",
  "LocalizedLabels": [
   {
    "@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
    "Label": "Serial Number",
    "LanguageCode": 1033
   }
  ]
 },

 "RequiredLevel": {
  "Value": "None",
  "CanBeChanged": true,
  "ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
 },

 "SchemaName": "new_SerialNumber",
 "AutoNumberFormat": "WID-{SEQNUM:5}-{RANDSTRING:6}-{DATETIMEUTC:yyyyMMddhhmmss}",
 "@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata",
 "FormatName": {
  "Value": "Text"
},
 "MaxLength": 100
}

 

You just have to pass certain headers in the API request such as Content -Type , Application as JSON and the authentication.

Once you have done this – you will see a a new field as new_serialnumber has been created in the system under new entity. Few things:

  1. Put the field on the form
  2. it will be a locked field
  3. it will generate a new number everytime you click on save

it will be something like below:

Untitled

 

I hope this helps!

 

Business Process Flows – JavaScript

Microsoft Dynamics 365 and Unified Service Desk

Recently I published a post describing how to access the various components of a business process flow, including the currently active process flow, details about the stages in the process and also the steps within the stage.

Here I will build upon that post and look at what actions can be performed on a business process flow.

Get active Stage

If you need to get the name or Id of the current stage, follow code below;

var activeStage = Xrm.Page.data.process.getActiveStage();

alert(activeStage.getId());

alert(activeStage.getName());

To hide the active business Process Flow

Xrm.Page.ui.process.setVisible(false); // ** Or true

To expand or collapse the active business process flow

Xrm.Page.ui.process.setDisplayState("collapsed"); // *** Or expanded

Move to next stage in the business process

You can use the moveNext method to navigate to the next stage in the business process. As shown below;

var activeProcess = Xrm.Page.data.process.getActiveProcess; if (activeProcess != null) { Xrm.Page.data.process.moveNext(function (result) { if (result…

View original post 198 more words