Friday, September 28, 2018

Hiding Site Map Menu option for different Security Role in Dynamics 365 CRM


I believe there is a need to do more practicals when playing with hiding menu options from Site map in dynamic 365 CRM. 
So I am creating this blog with only practicals.

Visit previous blog which is having steps to hide navigation menus

Hide Navigation Menu in Dynamic 365 CRM


Here I would be presenting a small practical to hide / show navigation menu in Dynamic 365 CRM. I would be playing with Product Catalog under setting area

I have created two security Role to test if it is working as expected.

1) Salesperson ---- DO NOT Show Products




When Users logged in, he sees no Product Catalog.




2) Salesperson ---- Show Products




Now when Users logged in with Read privileges on HideNavigationItem entity, he sees Product Catalog menu option.




Just considering the last case, what if a user’s has been assign with both such security role.



He will see the Product Catalog as we get the union of both security role :)

Thanks.
Vipin Jaiswal
vipinjaiswal12@gmail.com



Wednesday, September 26, 2018

Workflow has errors and cannot be published in Dynamic 365 CRM


The selected workflow has errors and cannot be published. Please open the workflow, remove the errors and try again.

Just another day, I deployed my solution from development to test environment and was doing just sanity checking if everything is all OK.

To my surprise, I saw few workflows were in Draft instead of being in Active state. There was a Red Cross icon at the very first step of the workflow and it did not help with nothing.

No Specific row was highlighted to at which might be the culprit and causing an error.




Bug Identified:
  • The lookup value in workflow conditions, were missing in the source environment.
  • The lookup value can also be a part of email template Sender or Recipient (To or CC) which might not exists.
  • Especially when we have Email Queues created for specific environment and get missed every time when we promote workflow.



Tuesday, September 18, 2018

ID3242: The security token could not be authenticated or authorized.



When connecting to Microsoft Dynamics CRM from Console application C# was getting an error message “ID3242: The security token could not be authenticated or authorized”?

I recently had this issue when connecting to Microsoft Dynamics CRM configured with Active Directory Federation Services(ADFS).


My C# Code is simplified using Microsoft.Xrm.Tooling.Connector.dll

String connectionString = ConfigurationManager.ConnectionStrings[1].ConnectionString;
CrmServiceClient conn = new CrmServiceClient(connectionString);         

// Cast the proxy client to the IOrganizationService interface.
_orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ?
(IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

Guid orgId = ((WhoAmIResponse)_orgService.Execute(new WhoAmIRequest())).UserId;


My App.config Settings were

<add name="Server=CrmServerAddress, organization=CrmOrg, user=CrmAdminUser"
connectionString=   "Url=https://crmserveraddress/crmorg;
                     Domain=myDomain
                     Username=CrmAdminUser;
                     Password=*********;
authtype=IFD"/>


I could still access Dynamics CRM through the browser just fine but not from my console application.

To resolve the issue it was a very simple change. It seems that with the upgrade of ADFS it has now required the UPN (user principal name / MSDN – User Name Formats) login in order to authenticate. That is simply going from the domain login to the email address like this:


Another option that worked was to use the Down-Level logon name (Domain\username)

myDomain\CrmAdminUser

If you receive such an error while trying to connect Dynamic CRM from console C# application or anything else that consumes the Dynamics CRM services, change user name and maybe you’ll be back up and running a little quicker.

I hope this helps!


Thanks.
Vipin Jaiswal


Saturday, September 1, 2018

Dependent OptionSet(Picklist) consideration in Dynamic 365 CRM


Recently I was strike again with a very old and familiar requirement that we all might have come across in Microsoft Dynamic CRM –
How to create a dependent Pick-list/Option set list where the options of Second Pick-list are dependent on the Value of the First one.

We can achieve multilayer of dependency for so-called Pick-list/Option Set in Microsoft Dynamic CRM with the help of

           JavaScript coding, Form and Field level customization

Here is MSDN article which help to Create dependent OptionSets (picklists)


You can find a very relevant tool (Dependent OptionSet Generator) to help in development of dependent picklist faster https://crmoptionsets.azurewebsites.net/




!!! Question is there a better way to achieve such requirement.

Can we not achieve this by using a Filtered lookup – no coding involve – will you not be happy with just customization and a much faster development!

Let us try to evaluate some benefits of using Filtered Lookup.
  • Form's Related Records Filtering functionality to control the available selection of list items
  • Easily add and deactivate list items, without changing any code.
  • Almost no coding and debugging involved and a much faster development.
  • Large dataset can be easily imported into lookup entities.


Disadvantage of Filtered Lookups
  • Require creation of entities for possibly just one value.
  • Report performance and other such retrieval performance problem as it may cost you with joins and linked entity.
  • What if someone accidentally delete any record, it will be gone from all our records.
  • All security role then must have full READ permission for such entities, otherwise user might face problem.
  • Waste of resources-creating entities will have tables in SQL and other unnecessary empty fields would been created.
  • Once the record is selected in Lookup and if user need to change then, it require more clicks.




Benefits of Optionset
  • They are faster in form rendering, reports and any other retrieval operation.
  • Neat and Clean
  • Complete control from System Admin and System Customizer

Disadvantage of Optionset
  • Require developer to code
  • A little complex to play with Json configuration to add and remove optionset values.



One more CHALLENGE to our Implementation

Can we consider some more factor here ?
  • Importing Data via Import Job  
  • Bulk edit using Excel Online
  • Integration with other System

As our implementation from either Dependent Picklist or Filtered Lookup are JavaScript (Client-side), they will ignore all validation that might be our Prime Objective.

So in this scenario, we need to implement Pre-Validation plugins, which will restrict user to not to select wrong options.  

I hope there will be more consideration to come with such a small requirement J.

Thanks,
Vipin Jaiswal