Monday, 15 April 2019

D365 CE Quick Hacks - Switch to UCI from Classic UI - ForceUCI

With D365 CE there are lot of cool stuff's happening, we are right in middle of all the rapid evolution of the industry and product.

Before reading below content around UCI/Classic app, its recomended to go through below blogs, 



Its always handy to have URL's in armory to navigate to specific areas/interfaces with ease. Lets have a look at them now

How to quickly navigate to default UCI app from Classic UI?

Append a forceuci Query string parameter after main.aspx
https://<your orgname>/main.aspx?forceuci=1 

Ex: https://contoso.crm.dynamics.com/main.aspx?forceuci=1

How to quickly switch the current Classic app to UCI?

Append a forceuci query string parameter after appid. Please make sure to remove session idenfier("#<somerandomnumber>") before appending foreuci tag.

https://<your orgname>/main.aspx?appid=<yourappid>&forceuci=1 

Ex: https://contoso.crm.dynamics.com/main.aspx?appid=ec876248-c755-e911-a832-000d3a127836&forceuci=1

Happy Learning!

Sunday, 14 April 2019

D365 CE Quick Hacks - Switch to Classic UI from UCI - ForceClassic

With D365 CE there are lot of cool stuff's happening, we are right in middle of all the rapid evolution of the industry and product.

Before reading below content around UCI/Classic app, its recomended to go through below blog, 

Its always handy to have URL's in armory to navigate to specific areas/interfaces with ease. Lets have a look at them now

How to quickly navigate to default Class UI app when the "UCI only" setting is enabled?

Append a forceclassic Query string parameter after main.aspx
https://<your orgname>/main.aspx?forceclassic=1 

Ex: https://contoso.crm.dynamics.com/main.aspx?forceclassic=1

How to quickly switch the current UCI app to Classic UI?

Append a forceclassic query string parameter after appid. Please make sure to remove session idenfier("#<somerandomnumber>") before appending foreclassic tag.

https://<your orgname>/main.aspx?appid=<yourappid>&forceclassic=1 

Ex: https://contoso.crm.dynamics.com/main.aspx?appid=ec876248-c755-e911-a832-000d3a127836&forceclassic=1

Happy Learning!

Saturday, 13 April 2019

D365 CE - Set Classic UI or Navigate to Classic UI

With the introduction of the power platform and UCI lot of the settings in customer engagement is evolving rapidly. One of those were, the UCI is the default interface and not able to get into the classic UI.

Now I am on UCI, how to I navigate to the settings area that controls UCI/Classic UI?

Option 1:

  • Using the setting gear icon on the right hand top corner and select advanced setting.
  • Navigate to Settings => Administration => System settings
Option 2: 
Option 3:
  • Go to URl "https://<your org>/main.aspx?settingsonly=true"
  • Navigate to Settings => Administration => System settings

Under general tab you would see below options,(In powerplatform admin you might see this under basic behaviour section)
    • Set "Use the new Unified interface only" option to No




Friday, 8 March 2019

D365 - Revise Quote using Workflow - ReviseQuoteRequest

As a result of constant feature rich updates from MS Team, we were able to call actions from workflows which personally if one of my favorites. I am exploring lot of options around the same, one such is revising the Quote via Workflow.

Why should I need this as I already have a ribbon button to achieve this?

Many businesses have their own business specific quote processflow which might not be in sync OOB quote process flow. In such situation we might need this revise option to minimize the coding effort and leverage OOB revision process. 


Lets not wait anymore, diving into the configuration

1. Create a workflow against quote(Set Scope and sync/async)
2. Hit "Add Step" => "Change Status". Set the status to Closed(Lost/Won/Cancelled) as only closed quotes can be revised using "ReviseQuoteRequest". In this case I am setting it to Closed(Cancelled).

3. Hit "Add Step" => "Perform Action". Select "Revise" against Action optionset and "Quote" should be auto selected against Entity optionset.

4. Hit "Set Properties" => select current quote as dynamic value against QuoteId

Happy Learning!


Thursday, 7 March 2019

D365 CE - JS Deprecated Methods cheatsheet - Xrm.Page deprecated and replaced by formContext



Its important for every dynamics developer to understand the deprecated functionalities so that we can stay away from them in our current implementations. This would save lot of time and money when it comes to upgrade and rework when the functionalities are obsolete.

JavaScript is a key piece in  Dynamics UI tuning and with D365 there are a wave of updates when it comes to JS and its hard to remember all the deprecated methods/objects so Microsoft has provided a cheat sheet for deprecated methods. I have copy pasted the same below, please make use of it.


Deprecated Client API
Replacement Client API
Comments
Forms: ExecutionContext.getFormContext 
Commands: Send it as the PrimaryControl parameter
Use of the Xrm.Page object as a static access to the primary form context is still supported to maintain backward compatibility with the existing scripts. Based on the feedback, we understand that the usage of Xrm.Page is high, and it won’t be removed as soon as some other client API methods listed in this section. We encourage you to use the new way of getting form content where possible. More information: Client API form context
Although Xrm.Page is deprecated, parent.Xrm.Page will continue to work in case of HTML web resources embedded in forms as this is the only way to access the form context from the HTML web resource.
Xrm.Utility.getGlobalContext
Allows access to the global context without going through the form context.
formContext.data.attributes
The formContext.data.attributes API will make retrieval of non-entity bound data consistent across entity forms, metadata-driven dialogs, and task-based flows. The data will be a combination of custom values sent using the query string and what was specified in the parameters in the openForm method.
globalContext.userSettings.getTimeZoneOffsetMinutes
Moved to globalContext.userSettings
globalContext.userSettings.userId
Moved to globalContext.userSettings
globalContext.userSetings.languageId
Moved to globalContext.userSettings
globalContext.userSettings.userName
Moved to globalContext.userSettings
globalContext.userSettings.securityRoles
Moved to globalContext.userSettings
globalContext.organizationSettings.isAutoSaveEnabled
Moved to globalContext.organizationSettings
globalContext.organizationSettings.languageId
Moved to globalContext.organizationSettings
globalContext.organizationSettings.uniqueName
Moved to globalContext.organizationSettings
No change in the method, but use "typename" instead of type for lookup attributes.

GridRow.data
GridRow is essentially a form context. This change unifies the interface of GridRow with formContext.
GridRowData.entity
GridRowData is form data. This change unifies the interface of GridRowData with formContextData.
Xrm.Mobile.offline
Moved the offline-related methods under Xrm.WebApi.offline

Earlier: An HTML web resource may interact with the Xrm.Page or Xrm.Utility objects within the form by using parent.Xrm.Page or parent.Xrm.Utility. 
Now: parent.Xrm.* will work if the HTML web resource is loaded in a form container. It won't work for HTML web resources that are stand alone, or referenced from the site map or any other places.
addOnKeyPress
Use a custom control

removeOnKeyPress
Use a custom control

showAutoComplete
Use a custom control and corresponding UI

hideAutoComplete
Use a custom control and corresponding UI

Xrm.Navigation.openAlertDialog
The new signature is consistent with other APIs (openForm) and takes a new set of parameters for flexibility.
Xrm.Navigation.openConfirmDialog
The new signature is consistent with other APIs (openForm) and takes a new set of parameters for flexibility.
Xrm.Utility.getEntityMetadata
The isActivityType method is synchronous so it was suitable for ribbon rules. However, the replacement method, getEntityMetadata, is asynchronous, and is not suitable for ribbon rules.
Xrm.Navigation.openForm
Moving navigation actions to Xrm.Navigation
Xrm.Navigation.openForm
Moving navigation actions to Xrm.Navigation
Xrm.Navigation.openWebResource
Moving navigation actions to Xrm.Navigation 
Note: This API returns VOID in Unified Interface.


Sunday, 3 March 2019

D365 CE - Quote Revise Approach and Error Troubleshooting - The quote cannot be revised because it is not in closed state.

I have recently faced an error while revising an active quote using ReviseQuoteRequest action via plugin/workflow. Below is the error message

"The quote cannot be revised because it is not in closed state. If you contact support, please provide the technical details."

Root Cause
Its due to the state of Quote. Only the quotes in closed state can be revised, if we are trying to revise a quote in a different state, then its going to error out with above message.

Fix/Approach
  1. First change the Quote status to Closed(Won/Lost/Cancelled). 
  2. Then execute the ReviseQuoteAction which would result in new revised Quote as expected
You can read how to implement the above revise quote with a workflow here.

Wednesday, 6 February 2019

D365 Js Tips - Hide / Show / Enable / Disable a field - Best Practice Tip 1



Quick tip to avoid redundant code to enable/disable/show/hide a field. 

1. Hold the result of hide or disable condition in a variable.

Var isDisable =(formContext.getAttribute('accounttype').getValue()==1);
2. Use the result in disable rule so that it will flip between enable and disable without redundant script lines for enable/disable and avoids if branching

formContext.getControl("<Field Name>").setDisabled(isDisable);

Tuesday, 28 August 2018

{Know-how} D365 BPF - Business process flow Disable a field or make attribute readonly



Requirements are always crazy, suppose if you want to optionally disable or enable a field in BPF it is possible with XRM object model. The only change is the prefix which you need to add to your attribute's logical name

Xrm.Page.getControl("header_process_<field logical name>").setDisabled(bool);

Friday, 27 July 2018

D365 - The attribute with AttributeId = 'Guid' was not found in the MetadataCache - MSCRM Solution Export


Error Message during solution export:
The attribute with AttributeId = <GUID> was not found in the MetadataCache.


Root Cause:
A field is deleted from CRM and the field is removed. But the related solution component reference is left behind somehow.


Fix:
Find the component related to the field and remove it.

Note: Make sure to have a back-up of DB or the Org before performing below operations. Need developer level knowledge to perform this!

Step 1: Find the missing component. Get the solutioncomponentid and componenttype by executing the following fetchxml  query after replacing the guid with the attributeid from the error message.

Note: You can XRM toolbox or C# console app to retrieve the record

<fetch top="50" >
  <entity name="solutioncomponent" >
    <all-attributes/>
    <filter type="and" >
      <condition attribute="objectid" operator="eq" value="<GUID>" />
    </filter>
  </entity>
</fetch>

Step 2: Get the "solutioncomponentid" and "componenttype"  from the result of above fetchxml query and use "RemoveSolutionComponentRequest" to remove the component.



var removeComponentReq = new RemoveSolutionComponentRequest()
{
    ComponentId = <GUID - objectid>,
    ComponentType = <int - componenttype>,
    SolutionUniqueName = <string - solution's uniquename>
};

Hope this helps!

Thursday, 19 July 2018

{Know-how} D365 BPF - Business process flow Hide a field or Attribute using JS



Requirements are always crazy, suppose if you want to optionally hide and show a field in BPF it is possible with XRM object model. The only change is the prefix which you need to add to your attributes logical name

Xrm.Page.getControl("header_process_<field logical name>").setVisible(false);

{Know-how} D365 Advanced Find - Query users based on team - Createdby/owner/modifiedby Team




In dynamics community forum, I came across an interesting querying scenario using advanced find, the requirement is to query all leads created by a team. As we all know, all records in CRM are created by user and user is a team member in a team . Lets see how to query the same using advanced find


Advanced find => select leads in look for =>In query builder select field/related => select related "Created By(User)" => under "Created By (user)" select related "Teams" => Under "Teams" select field "Team" => select the team as your value with operator "Equals"


Hope this helps!

Tuesday, 17 July 2018

{Know-how}MSCRM Ribbon - No rows could be found for LocalizedLabel with id if LocalizedLabel were published


Lets have look into a issue I recently faced and fix for the same. Also will include other references that can help to solve root cause.

Issue:
Error while publishing a ribbon customization at localizedlabel.
No rows could be found for LocalizedLabel with id 10000000-0000-0000-0000-000000000001 if LocalizedLabel were published

Fix:

  • Include only the entities that requires ribbon customization
  • Remove the attributes - This causes localized label issue for most part
  • Remove all other components in entity which are not needed

Root Cause:

The issue seems to be with a corrupted localized label and when the attribute is included, CRM tries to publish the localized label and it breaks. 

In the below forum they suggest to remove the same using direct SQL, I would suggest to raise a ticket with MS in case if you face this issue.

Sunday, 8 July 2018

D365 - Alternate Keys for Duplicate detection



Recently, I came across few scenario's where I needed duplicate detection for some of the Primary keys from multiple systems.

MSCRM alternate Keys are handy in performing duplicate detection and the alternate keys are primarily used for simplifying Integration and Migration activities. On top it implements the unique constraint for a columns or combination of columns and this can be an robust alternate to duplicate detection rules in few scenarios.


Points to Keep in Mind while designing:

  • Alternate Key allows Null values. 
  • Alternate Keys can be composite
  • Alternate Keys can be used for upsert, retrieve, update and delete. 
  • Do not go for too many alternate keys, this may impact performance as each key will be an index in DB. Seems to be a filtered index in DB


Setting up an alternate key(Copy pasted from MS blog):
To define the alternate keys, go to Go to Settings > Customizations.. Choose Customize the System > Components > Entities > Entity <X> > Keys. Choose New. On the form, fill in the required fields (Display Name and Name) and then choose and add the fields to the key. Save the key. In the example shown here, we used the Account Number field in the alternate key definition.
Define alternate key for the account entity

Wednesday, 25 April 2018

D365 CRM Solution Import - The element 'savedquery' has incomplete content -List of possible elements expected: 'LocalizedNames'



Error: 
The import file is invalid. XSD validation failed with the following error: 'The element 'savedquery' has incomplete content. List of possible elements expected: 'LocalizedNames'.'.


Background: 
When a MSCRM solution import fails at system views with "XSD schema validation failed" error 

Root Cause:
When a system view columns/filter/description is modified and added to solution. Sometimes solution export engine excludes the view(savedquery) name. I have noticed this in project service related views.

Fix:
  • Log into the environment where the solution is exported from and open the solution. 
  • Rename the view with some temporary name, then save and publish.
  • Again change the name back to it original state, then save and publish
  • Export again and re-import into destination

D365 CRM - Solution Import - Error occurred while fetching the report - SSRS



Solution Import Error:
Error occurred while fetching the report.

Background:
When a MSCRM solution import fails at reports and the error is something like "Error occurred while fetching the report"

Root Cause:
SSRS server is not up and running or having some issue. The same should also affect execution of reports in that instance. 

Thursday, 29 March 2018

{Know-how}D365 v9 Javascript - ConfirmDialog with custom labels

Below is a quick code snippet and output that can be used for customized confirm dialog

Code Snippet:
 var dialogLabelAndText = { confirmButtonLabel: "Proceed", cancelButtonLabel: "Clear & Exit", text: "This is a Confirmation Dialog", title: "Dialog" };  
   var dialogOptions = { height: 200, width: 450 };  
   Xrm.Navigation.openConfirmDialog(dialogLabelAndText, dialogOptions).then(  
     function (success) {  
       if (success.confirmed)  
         Xrm.Navigation.openAlertDialog({ confirmButtonLabel: "Yes", text: "Process completed!" });  
       else  
         Xrm.Navigation.openAlertDialog({ confirmButtonLabel: "Yes", text: "Exit and Clear Process!" });  
     });  

Output:

Thursday, 15 February 2018

D365 CRM V9 - Plugin Registration tool/SSRS/XRMToolbox connection error - Console App connection Error - TLS1.2


Wanted to pen down this for long time, but with latest info I have, it made perfect sense to share with our community regarding the recent connection errors

What is the issue?
When we try to connect to D365 V9 from Plugin registration tool, the connection fails without any proper error and loops back to organization selection screen or login screen.


What is the root cause? TLS1.2 is used in D365 V9 and older versions of TLS are not supported!
 Well document root cause available here
Some more info around TLS1.2


Available Fixes:
There can be multiple fixes to this issue, simplest one is install the latest version if available but that not an option right now.

Fix1: Get the latest version of Plugin Registration Tool my friend

The following fixes will also work with Console App/SSRS report authoring Extensions and I prefer the registry fix which seems permanent. Somehow XRMToolbox works only with registry fix.

Fix 2:This works only when fiddler is running(Temp Fix)

Note: Need Telerik Fiddler to be installed in the machine
  1. Open Fiddler
  2. Go to Tools in menubar => then select Options or Telerik Fiddler options 
  3. Open HTTPS Tab and look for the highlighted region in below image
  4. If it is missing TLS1.2, add the same by clicking it and save

Fix 3: Copied from Microsoft Article(Suggested fix - Needs Machine Restart)

  • Manually disable RC4 in TLS on systems running .NET Framework 3.5
    The following steps are primarily for customers running .NET Framework 3.5 on Windows 10 (or on Windows Server Technical Preview 3), for which an update is not available. However, for customer running .NET Framework 3.5 on all earlier affected operating systems, the manual steps serve as an optional alternative to installing the available update.
    Note These steps require the use of Registry Editor. Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk. For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or view the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe.
    1. Create a text file named strongcrypto35-enable.reg that contains the following text:
      For 32-bit applications on 32-bit systems and 64-bit applications on x64-based systems:
         [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
         "SchUseStrongCrypto"=dword:00000001
      
      For 32-bit applications on x64-based systems:
          [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]
          "SchUseStrongCrypto"=dword:00000001
      
    2. Run regedit.exe.
    3. In Registry Editor, click the File menu and then click Import.
    4. Navigate to and select the strongcrypto35-enable.reg file that you created in the first step. (Note If your file is not listed where you expect it to be, ensure that it has not been automatically given a .txt file extension, or change the dialog’s file extension parameters to All Files).
    5. Click Open and then click OK
    6. Exit Registry Editor and restart the system.
  • Manually disable RC4 in TLS on systems running .NET Framework 4.5/4.5.1/4.5.2
    Despite the fact that an update is available for systems running .NET Framework 4.5/4.5.1/4.5.2, the following steps are primarily for customers with .NET Framework 4.5/4.5.1/4.5.2 applications running on systems with .NET Framework 4.6 present. For customers running only .NET Framework 4.5, 4.5.1, or 4.5.2, the manual steps serve as an optional alternative to installing the available update.
    Note These steps require the use of Registry Editor. Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk. For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or view the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe.
    1. Create a text file named strongcrypto4-enable.reg that contains the following text:
      For 32-bit applications on 32-bit systems and 64-bit applications on x64-based systems:
          HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319
          "SchUseStrongCrypto"=dword:00000001
      
      For 32-bit applications on x64-based systems:
          HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319
          "SchUseStrongCrypto"=dword:00000001
      
    2. Run regedit.exe.
    3. In Registry Editor, click the File menu and then click Import.
    4. Navigate to and select the strongcrypto4-enable.reg file that you created in the first step. (Note If your file is not listed where you expect it to be, ensure that it has not been automatically given a .txt file extension, or change the dialog’s file extension parameters to All Files).
    5. Click Open and then click OK
    6. Exit Registry Editor and restart the system.


Wednesday, 14 February 2018

D365 CRM V9 Troubleshooting TLS1.2 - SSRS report connectivity Error - Report Authoring Extensions

Recently I had to develop an FetchXML SSRS report and found that I was not able to connect to D365 CRM V9 from Visual studio. I have faced a similar issue with Plugin registration tool and the same was sorted with latest version of Visual Studio. But I couldn't find any latest version of Report authoring extensions. Planned to write a quick blog to help fellow developers

What is the issue?
When we try to connect to D365 V9 from visual studio using report authoring extensions, the connection fails without any proper error and loops back to organization selection screen or login screen.


What is the root cause? TLS1.2 is used in D365 V9 and older versions are not supported!
 Well document root cause available here
Some more info around TLS1.2

Available Fixes:
There can be multiple fixes to this issue, simplest one is install the latest version if available but that not an option right now.

The fixes will also work with Plugin registration tool/Console/XRMtoolbox

Fix 1: This works only when fiddler is running

Note: Need Telerik Fiddler to be installed in the machine
  1. Open Fiddler
  2. Go to Tools in menubar => then select Options or Telerik Fiddler options 
  3. Open HTTPS Tab and look for the highlighted region in below image
  4. If it is missing TLS1.2, add the same by clicking it and save

Fix 2: Copied from Microsoft Article(Suggested fix)

  • Manually disable RC4 in TLS on systems running .NET Framework 3.5
    The following steps are primarily for customers running .NET Framework 3.5 on Windows 10 (or on Windows Server Technical Preview 3), for which an update is not available. However, for customer running .NET Framework 3.5 on all earlier affected operating systems, the manual steps serve as an optional alternative to installing the available update.
    Note These steps require the use of Registry Editor. Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk. For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or view the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe.
    1. Create a text file named strongcrypto35-enable.reg that contains the following text:
      For 32-bit applications on 32-bit systems and 64-bit applications on x64-based systems:
         [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
         "SchUseStrongCrypto"=dword:00000001
      
      For 32-bit applications on x64-based systems:
          [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]
          "SchUseStrongCrypto"=dword:00000001
      
    2. Run regedit.exe.
    3. In Registry Editor, click the File menu and then click Import.
    4. Navigate to and select the strongcrypto35-enable.reg file that you created in the first step. (Note If your file is not listed where you expect it to be, ensure that it has not been automatically given a .txt file extension, or change the dialog’s file extension parameters to All Files).
    5. Click Open and then click OK
    6. Exit Registry Editor and restart the system.
  • Manually disable RC4 in TLS on systems running .NET Framework 4.5/4.5.1/4.5.2
    Despite the fact that an update is available for systems running .NET Framework 4.5/4.5.1/4.5.2, the following steps are primarily for customers with .NET Framework 4.5/4.5.1/4.5.2 applications running on systems with .NET Framework 4.6 present. For customers running only .NET Framework 4.5, 4.5.1, or 4.5.2, the manual steps serve as an optional alternative to installing the available update.
    Note These steps require the use of Registry Editor. Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk. For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or view the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe.
    1. Create a text file named strongcrypto4-enable.reg that contains the following text:
      For 32-bit applications on 32-bit systems and 64-bit applications on x64-based systems:
          HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319
          "SchUseStrongCrypto"=dword:00000001
      
      For 32-bit applications on x64-based systems:
          HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319
          "SchUseStrongCrypto"=dword:00000001
      
    2. Run regedit.exe.
    3. In Registry Editor, click the File menu and then click Import.
    4. Navigate to and select the strongcrypto4-enable.reg file that you created in the first step. (Note If your file is not listed where you expect it to be, ensure that it has not been automatically given a .txt file extension, or change the dialog’s file extension parameters to All Files).
    5. Click Open and then click OK
    6. Exit Registry Editor and restart the system.