Showing posts with label General. Show all posts
Showing posts with label General. Show all posts

Aug 9, 2022

How to track the changes done for a Workflow

There are two parts to the question. If you have written Custom workflow Activities, obviously you have written in Visual Studio (Or similar Dev tool) and may have stored in a repository. In fact, you are all good to track back what changes are made by developers in different occasions. 

Tricky part comes next: How to track down the changes done to a Workflow through the OOB workflow template. That’s adding/ removing different actions such as Create, Update etc. Unfortunately, there is no proper method. 

Anyway, there is a little trick. If Workflow was commissioned to the system for a while (Async or real time), chances are there could be sessions those failed. Failed sessions are always kept associated to the workflow. 

Now if you check an old failed session, you will be able to see all the steps existed in the workflow at that time. This is not a perfect solution, but I managed to explain an issue in one of my projects today by doing this to prove someone has removed an essential step. Unless this method, no one would be able to explain.

Thought of sharing since this could help someone!

Apr 4, 2019

Enabling Multi-Factor Authentication (MFA) for Microsoft users

Multi-factor authentication (aka MFA) is a new necessity in ever growing need for secure business systems. No exception for Dynamics 365. It is now possible for Dynamics since Microsoft users are easily enabled for MFA. In fact, any Microsoft application, including Dynamics products, are ready with MFA.

Let’s see the easy steps to enable MFA.

1.Enable users for MFA

Login to Office Admin center and click Active Users. Then click More> Multifactor Authentication Setup.


Resulting window will list down all the active users as below. Then you are allowed to pick the users those need MFA to be enabled and click Enable link.


Then you will see below general confirmation pop-up.


Upon confirmation, you will be notified on success of operation.


2. First time login

When user log to the system for the first time, below form will be presented to grab the phone number details.


One filled and submit, code will be sent to the given mobile for verification.


Once verify with the code, resulting pop-up will produce one important piece of information which is the app password. This is the password user is required to use for the situations mobile authentication is not possible such as Integrations and different apps (Outlook etc.).

3. Subsequent logins

Now user is MFA enabled. Each time user is sent a code to the mobile and requested to provide it prior to successful login.

Sep 17, 2017

Importing Duplicate Detection Rules

Since early versions of Dynamics 365, we have been using Duplicate Detection rules and it is a handy feature. Ironically, still we can't import those rules with Solution. In most cases, users configure them in different environment and its not a big deal. Still, it can be error-prone and inconsistent.

So alternative is to consider Duplicate Detection Rule entities as reference data and import them using Configuration Migration Tool coming with SDK. Usually you will find this tool in below location of the SDK;

\SDK\Tools\ConfigurationMigration

Anyway, below are the two points to keep in mind when importing Duplicate Detection rules;

1) Rules should be Unpublished before importing.
2) Need to include both Duplicate Detection Rule and Duplicate Rule Condition in correct Order.


Hope this helps.

Jan 20, 2016

Delete duplicates and keep only the latest record

This SQL code could be helpful since it’s a general requirement to remove duplicates while keeping latest record.

Considered example, we have a primary key called Id and Account Number is the field we are concentrating on.

Though this code is a loop, this works quickly since loop goes only for records with duplicates.

DECLARE @AccountNumber uniqueidentifier
DECLARE @ID VARCHAR(50)

DECLARE _cursor1 CURSOR for
 SELECT A1.AccountNumber
 FROM Tbl_Account as A1
 WHERE A1.AccountNumber is not null
 GROUP BY A1.AccountNumber
 HAVING (SELECT COUNT(A2.AccountNumber) FROM  Tbl_Account A2 WHERE A2.AccountNumber = A1.AccountNumber)>1

OPEN _cursor1

FETCH NEXT FROM _cursor1 INTO @AccountNumber
WHILE (@@FETCH_STATUS = 0)
BEGIN

    SET @ID = NULL

    SELECT TOP 1 @ID = Id FROM Tbl_Account WHERE AccountNumber = @AccountNumber ORDER BY [ModifiedOn] DESC
    
    DELETE FROM Tbl_Account WHERE AccountNumber = @AccountNumber AND Id <> @ID
 

FETCH NEXT FROM _cursor1 INTO @AccountNumber
END      
CLOSE _cursor1

DEALLOCATE _cursor1

Enjoy!

Jan 18, 2015

Reading the record Id from CRM 2013 front end

This is just small tip. How developers grab the GUID of a record from the front end of CRM.

What I do is using frames[0].Xrm.Page.data.entity.getId() script in developer’s tool console. (by pressing F12)

Now does it work in CRM 2013?

Yep, but need to be quite careful. Since we don’t get new window for every record in CRM 2013, if you try this as it is, it would give you a wrong ID. (yes, WRONG!) As an alternative, always make your record popped out as a new window before applying this script.

Below Icon will pop-out your record.

Nov 10, 2013

Dynamics CRM toolkit for CRM online

This is an amazing step by Microsoft to leverage the development effort especially in online department. From here you can download the needful stuff.

Also check this article for one of the clear explanations on how to get started;

http://mscrmshop.blogspot.com.au/2012/01/step-by-step-plugin-tutorial-using.html

Apr 29, 2013

How Queues work

This is a very good video on functionality of Queues of CRM 2011 works. This is simply yet clearly explained… though of sharing..



Nov 11, 2012

Importing CRM instance from different domain

Importing a CRM instance can be quite tricky. Typically, we might need to get an identical instance from production server to a new developing server or wise versa.

I am explaining the steps with illustrations. This worked for me. As I see, we have three main tasks to be done. They are getting the backup from the existing database; restore it in new server and configuring the CRM using Deployment manager.

1) Getting the backup from the existing database

There is nothing new about this step rather than getting the full back up of the organization which is in the format of <NAME>_ MSCRM. Right click the db >tasks>Back up take you to the wizard. Under option I usually select below options;
 a) Override all existing backup sets
 b) Verify backup when finished
 c) Perform checksum before writing to media

2) Restore the database in new (destination) server
Right click any database> task>restore>database takes you to the wizard. Then change the database name as required in the format of <NAME>_ MSCRM, where NAME will be the name of new CRM instance. Then go to “From device” and browse to the database backup taken in the previous task.


3) Import/configure  the CRM instance

a. Go to Organizations node, right click the  select “Import Organization”, which will return below window with newly created database.


b. Give the name in both places


c. Specify the URL of reporting server for the instance and proceed.


d. When it comes to the user mapping window, select “Automatially map users” option and proceed.


e. Then you will probably get below error message.


Press Ok, you will get below window.


f. Now find the “System Administrator” from existing user column and assign it to yourself by licking the browse button.



If you forget to do this you will be thrown another error message like below one.


g. If you have done everything correctly, you will now see below window.


h. When you proceed, you will see below kind of summery.


i. Now you are ready with new instance.


Now you are ready to work with new instance.

However, keep in mind; you may need to take below steps depending on the customizations done in your system.

1) If you have any kind of configuration files, you need to copy and change as required.
2) If you have done Plug-ins you must copy those DLL files to Program Files\Microsoft Dynamics CRM\Server\bin\assembly
(Open the plug-in registration tool and notice your plug-ins are already registered correctly)
3) Add other users of domain your new CRM is placed.

Jul 16, 2012

Script error of Follow up button

When clicking the Follow up button, sometimes users see a script error as by the bottom left of corner of the browser.


This occurs since your form assistant is disabled. Obviously, this is a contradiction.  Follow up pane should get loaded in form assistant section, which is not available.

Form Assistant and Follow up
So, when you design the form, you have to think Follow up functionality together with form assistant.

1) Option 1: If you want follow up, your form assistant should be enabled
For this, go to customizations > Open relevant entity > click Forms and Views > Open Form > Open Form prosperities > Click display tab.
Then enable the Form assistant by clicking the check box.


2) Option 2: If you want form assistant to be disabled, follow up button should be removed
How to remove the button using JavaScript is discussed here.

Decide this in terms of your useability expectations.

Mar 4, 2012

Calculate business days in c# (with variable business days per week)

One of my past posts (i.e. here) I discussed calculating hire days in JavaScrips for equipments (including start and end days) with variable number of days per week. It could be 5 as a default, but one can work on Saturdays too and also there can be non-stop operations which we should count 7 days per week. Here is the appropriate c# code.

public static int getHireDays(DateTime startDate, DateTime endDate, int NoOfDays)
        {
        int _saturdays = 0;
        int _sundays = 0;
        int _Bdays = 0;

        endDate += TimeSpan.FromDays(1); //add one beacuse we need days INCLUDING end date
        long ticks = (endDate.Ticks - startDate.Ticks) / 10000000; //seconds
        int days = (int)(ticks / 86400);

        endDate -= TimeSpan.FromDays(1);
        for (DateTime i = startDate; i < endDate; i += TimeSpan.FromDays(1))
        {
            if (i.DayOfWeek == DayOfWeek.Saturday) { _saturdays = _saturdays + 1; }
            if (i.DayOfWeek == DayOfWeek.Sunday) { _sundays = _sundays + 1; }
        }

        switch (NoOfDays)
        {
            case 5:
                _Bdays = days - (_sundays + _saturdays);
                break;
            case 6:
                _Bdays = days - _saturdays;
                break;
            case 7:
                _Bdays = days;
                break;
        }
        return _Bdays;
        }

Since I am doing a loop here, this can be bit inappropriate for long periods, but I haven’t tested the performances for long periods.

Oct 31, 2011

I miss you DeletionStateCode!

While I was trying to study bits and pieces of CRM 2011, I noticed that DeletionStateCode is not more available in entities. This is a signal that I need to be careful when deleting the records :-)

If I delete an important record, I might not be able to recover the record, because its being deleted in the real time.. I might miss "DeletionStateCode" badly!

Sep 13, 2011

DateFormats and Ascentium CrmService

Playing around with DateTimes seems quite hectic to me. Specially, when you work in client side with Ascentium CrmService, it becomes tricky since you need to do your operations in usual DateTime format available in JavaScript and convert them from/to methods in the service.

For example, if you need some DateTime operation done in your logic using JavaScript, for some value comes from a Fetch result, first you need to convert them to a DateTime field. Fetch returns strings. There is no simple way for that but to do it with some string operations as below.

//convert DATE String (2008-01-01T00:00:00) format 
//to DATE (Tue Aug 23 07:00:00 UTC+1000 2011)
DateFormatFromAttributeValue = function(DateStr)
{
    var yearStr, YearStr, DayStr, MonthStr, HourStr, MinStr, NewDateStr;
    yearStr = DateStr.substr(0, 4);
    MonthStr = String(DateStr.substr(5, 2) - 1); //Month goes as 0-11
    DayStr = DateStr.substr(8, 2);
    HourStr = DateStr.substr(11, 2);
    MinStr = DateStr.substr(14, 2);

    return new Date(yearStr, MonthStr, DayStr, HourStr, MinStr, 0);
}

It is interesting to see that you get three string values from the Fetch as below.


My advice is to use “value” field for all your operations even if you need just the date. I am telling this because, date string is not consistent with the length which could drag you to a mess when handling. If you see carefully, in above example, date is shown as “2” not “02”. In fact, number of characters in the string could be different when date is less than 10th day and greater than 10th Day. This should be a big concern when string functions are being used for conversions.

When you need to submit a DateTime, you got to convert it back to the previous string format (i.e. 2008-01-01T00:00:00). I use below method for that.

//convert DATE (Tue Aug 23 07:00:00 UTC+1000 2011) 
//to DATE String (2008-01-01T00:00:00) format
DateFormatPassToService = function(DateValue)
{
  var YearStr, DayStr, MonthStr, HourStr, MinStr, NewDateStr;
  YearStr = DateValue.getFullYear();
  MonthStr = String(parseInt(DateValue.getMonth()) + 1); //Month goes as 0-11
      if (MonthStr.length == 1) { MonthStr = '0' + MonthStr; }
  DayStr = String(DateValue.getDate());
      if (DayStr.length == 1) { DayStr = '0' + DayStr; }
  HourStr = String(DateValue.getHours());
      if (HourStr.length == 1) { HourStr = '0' + HourStr; }
  MinStr = String(DateValue.getMinutes());
      if (MinStr.length == 1) { MinStr = '0' + MinStr; }
  return (YearStr + '-' + MonthStr + '-' + DayStr + 'T' + HourStr + ':' + MinStr + ':00');
}


Hope this will help you.

Jul 7, 2011

Getting rid of browser messages

Whatever the solution you provide for a client, it is important to think about it, in terms of useability engineering aspects. Simply, system should be user friendly. Recently, I came across a requirement of getting rid of two standard message pop-ups, come on the flow of actions. Though, I understood those are not errors, according to the users point, it was obviously not necessary; wastage of time.


Above message is the standard Internet explorer message which is thrown to tell you that form was not saved, but you are trying to move away. In most of the cases, when user has just one checkbox to allow some action for an existing record, user has to do that, save it and again proceed... This seems wastage of time. In such cases, we have to make it simple by saving form when user clicks to checkbox.

if (crmForm.all.new_readyForProcess.checked) 
{
    if (crmForm.FormType == CRM_FORM_TYPE_UPDATE) 
    {
        crmForm.Save();
    }
}


Other case is refreshing the form after some action such as status change. Though, browser throws this message with a big reason, it’s not applicable in these kinds of cases.


Instead of refreshing, loading the page again would help you getting rid of this message.

//window.location.reload(true); 
sURL = unescape(window.location.pathname);
window.location.href = sURL + '?id=' + crmForm.ObjectId;


Quite simple..

Jun 23, 2011

Enhancing the Lead conversion functionality

Converting a lead to an Account/Contact/Opportunity is a standard function provided by Dynamic CRM. Either you disqualify the lead or qualify (convert). Modifying the provided convert page is quite restricted. Below article shows how to hide some of the covert options.

If you want to covert the lead to some other entity, for example, to a custom entity, it’s impossible with standard convert page. When I came across this requirement, I implemented a solution without the standard page.

This solution was flexible, but contained few steps.

1) Hide the button to the standard lead convert page.
2) Add my own menu system to lead entity
3) Implement disqualify method
4) Implement qualify(convert) method

Will consider the steps in detail;

1) Hide the button to the standard lead convert page.

I could call below method to hide the lead convert button.

hideStandardQualifyingButton = function() 
{
var lis = document.getElementsByTagName('LI');
var i = 0;
while (i < lis.length) 
{
    if (lis[i].getAttribute('title') == 'Qualify or disqualify the lead') 
    {
      //lis[i].outerHTML = '<SPAN></SPAN>' this gives errors for resizing the window afterwords
      lis[i].outerHTML = '<SPAN> <SPAN> <SPAN> <SPAN> </SPAN> </SPAN> </SPAN> </SPAN>'; 
    }
    i = i + 1;
}
}


If you check the web, you will see few places that suggest this code with the line I have commented. That works fine, but throws a page error when user resizes the browser window. Then the next line was introduced, instead.

2) Add my own menu system to lead entity



If you have play around with ISV file, this won’t be a hard task. Below are the new entries in lead entity for this.

<CustomMenus>
              <Menu>
                <Titles>
                  <Title LCID="1033" Text="Lead Conversion" />
                </Titles>
                <MenuItem JavaScript="LeadQualify();">
                  <Titles>
                    <Title LCID="1033" Text="Lead Convert" />
                  </Titles>
                </MenuItem>
                <SubMenu>
                  <Titles>
                    <Title LCID="1033" Text="Disqualify" />
                  </Titles>
                  <MenuItem JavaScript="LeadDisQualify(4);">
                    <Titles>
                      <Title LCID="1033" Text="Already Known" />
                    </Titles>
                  </MenuItem>
                  <MenuItem JavaScript="LeadDisQualify(6);">
                    <Titles>
                      <Title LCID="1033" Text="No Longer Interested" />
                    </Titles>
                  </MenuItem>
                </SubMenu>
              </Menu>
            </CustomMenus>


3) Implement disqualify method

This is the simple code you can use to disqualify the lead. ReasonCode is the integer value of disqualification reason.

oService.SetState("lead", _leadid, "Disqualified", ReasonCode);


If you want to further extend the disqualifying reasons, it’s possible. You can simply add whatever the new entries in entity in the standard way as below.

Now you can pass the relevant values to the same method. (Of course you need to add/edit the menu items in step 2 accordingly)

4) Implement qualify(convert) method

This is where you get the real fruit of the exercise. Now you can programmatically do your steps to convert your lead to any entity, including your own custom entities. For example this is a simple code I used to convert the lead to a custom entity called regional project (new_regionalproject).

var _leadid = crmForm.ObjectId;
    var _bEntity = new BusinessEntity("new_regionalproject");
    _bEntity.attributes["originatingleadid"] = _leadid;
    _bEntity.attributes["firstname"] = _firstName;
    _bEntity.attributes["lastname"] = _lastName;
    ....
    ....
 return _oService.Create(_bEntity);

Now we need to change state of the lead to qualified.

oService.SetState("lead", _leadid, "Qualified", 3);


Notes:

1) In step 4, you can actually implement any business logic since you are free to write the code before qualifying the lead. You can even Update or Associate with other entities accordingly.
For example I have converted the lead to account and created a Quote (without Quote products) using particular account as the potential customer.

2) In qualifying/disqualifying, you got to use the given methods. (i.e. SetState) Don’t try to call Update method here Since its not allowed.

Hope this will help you.

Jun 19, 2011

Ascentium CrmService - A good friend

Ascentium CrmService is one of the good friends of mine. Specially, when it comes to catering the customers need in CRM customization client side work does a massive role. Ascentium CrmService virtually helps in doing most of the things with its own methods that saved a lot of time. Please check this by yourself.