Tip #575: Check your clocks

tl;dr

Don't look at our crotches while we synchronize our watches!If you receive an error “An error occurred when verifying security for the message” when connecting to Dynamics CRM, verify that the clocks on the client and the servers are no further than 5 minutes apart.

Just a bit longer

Code that was working yesterday refuses to run and spits an error on the very first message sent to CRM:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
The clue is, in fact, in the inner message:
An error occurred when verifying security for the message.
Quick search reveals that I’m not the only one, and it’s been dealt with before by analyzing server logs (not available, of course, for CRM Online but on-premises it’s a good option). Step by step troubleshooting instructions are in the knowledge base article that deals with Outlook connectivity issues (the root cause is the same).

Worth noting that the lines:

CrmConnection con = new CrmConnection("connstring");
OrganizationService svc = new OrganizationService(con);

do not mean “connecting to CRM”. Connection will not be authenticated until the first use. That’s why, where applicable, I tend to write:

CrmConnection con = new CrmConnection("connstring");
OrganizationService svc = new OrganizationService(con);
svc.Execute<WhoAmIResponse>(new WhoAmIRequest());

that way, if it fails, it’ll be very early in the execution.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #574: Hidden sources of javascript errors

Quite often developers complain about getting javascript errors when the form does not contain any scripts or events. Explicit script definitions are not the only source of the possible errors:

  • Business Rules are deployed on the client as generated javascript. While it’s unlikely that business rules will generate an erroneous script, it’s worthwhile disabling the rules and see if the problem goes away. For CRM Online you can check the scripts generated using Business Rules Viewer at http://xrm.tools.
  • If the form contains html web resources, those resources can load scripts that interact with the form:

    An HTML web resource may interact with the Xrm.Page or Xrm.Utility objects within the form

  • Application and entities ribbons can load javascript resources as part of the action definition. You can check the presence of the commands by inspecting the ribbons using Ribbon Workbench. Note: if you entity does not have any ribbon definitions, it’s not a get our of jail free card. Third-party managed solutions can add their own command definitions to the ribbons and they won’t appear as part of your entity customizations. Hunting down those is a hit and miss exercise, vendor documentation and visual inspection of the ribbons and comparing them with the default ones is a good start.

Did we miss anything? Tell us at jar@crmtipoftheday.com.

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #573: CRM Online vs CRM On-premises features FAQ

Celebrity deathmatchSomeone at Microsoft has heard our online vs on-premises battle and decided to resolve it once and for all.

CRM 2016 – Online vs on-premises features FAQ is now available on the Help & Training site.

Some things are interesting and unexpected, others – not so much (like “Switch or delete an instance of CRM Online” feature is available for CRM Online only. Well, duh…)

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #572: Tipster guide to Dynamics CRM 2016 Customizing for Interactive Service Hub

if(today == Friday) 
{
   post.Category = Categories.Video;
}

In this video we introduce to the new customizations options that are available for the new Interactive Service Hub as part of Dynamics CRM 2016. We will look at the new interactive Dashboards, entity forms, and entity dashboards.

Give us your feedback, all of it: good, bad, and ugly, I’m sure we can take it. Suggest new topics either in comments or by sending your ideas to jar@crmtipoftheday.com.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #571: Unable to publish solution with calculated fields

If you attempt to publish a solution containing an entity with calculated fields, you may receive the following error message:

Field foo_calculated cannot be created or updated because field foo_used_in_condition_or_formula contains an additional formula that uses a parent record.

The wording is misleading and confusing because field foo_used_in_condition_or_formula is not a calculated field at all. The error is documented as:

ErrorId ManagedErrorName ErrorMessage
80060433 CalculatedFieldsEntitiesExceeded Field {0} cannot be created or updated because field {1} contains an additional formula that uses a parent record.

Which does not make it even remotely clearer.

What the error is trying to say is that there is a child entity with calculated fields that refer to foo_calculated field. Solution, as it turns out, is very simple:

If your entity contains a calculated field that is used in formulas of calculated fields of another (child) entity, make sure to include this child entity in your solution

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #570: Remote debugging in CRM with vorlon.js

Our resident visual effects tipster asked me the other day if I had any experience with using vorlon.js in CRM. I didn’t as I never heard of it. But since someone somewhere some time ago pointed out that these days <random noun>.js is probably a valid javascript library, I decided to take a look.

As it turns out, vorlon.js is a very cool

An open source, extensible, platform-agnostic tool for remotely debugging and testing your JavaScript. Powered by node.js and socket.io

Steps to enable vorlon for your CRM:

  1. Install node and npm. Easiest way to do it is to use PowerShell
    install-package -name nodejs
    install-package -name npm
    
  2. CRM won’t allow loading anything over http and we’ll need a certificate that we can generate ourselves using openssl.
    install-package -name "openssl.light"
    openssl genrsa -des3 -out server.key 1024
    openssl req -new -key server.key -out server.crt
    copy server.* c:\temp
    
  3. To make browsers to trust our dodgy certificate, import server.crt into Trusted Root Certification Authorities store (e.g. using mmc certificate snapin)
  4. Install vorlon
    npm i -g vorlon
    
  5. Modify server/config.json to enable ssl
        "useSSL": true,
        "SSLkey": "c:/temp/server.key",
        "SSLcert": "c:/temp/server.crt",
    
  6. And run it
    vorlon
    
  7. Open browser and point to https://localhost:1337. We have a lift off but now what?
  8. Create an html web resource and insert it into any CRM form
    <html>
      <head>
        <script 
          src="https://localhost:1337/vorlon.js">
        </script>
      </head>
      <body>
        <h1>Vorlon</h1>
        <p>Vorlon lives here</p>
      </body>
    </html>
    
  9. Load that form
    Vorlon host on CRM Form
  10. And here you have it!
  11. Object explorer in Vorlon

  12. You can now use console, for example, peek at the data
    Look at the data with Vorlon

Big deal, you say, because you can use magic F12 and achieve the same result? Well, yes, except all of the above works remotely, e.g. you can debug stuff on the user’s machine over the network.

Early days, of course, few additional notes to get you going:

  • DOM explorer is not very useful as its root is at the resource level. Injecting vorlon into CRM window is probably an option to consider
  • Create delayed load to debug only when needed. (See vorlon.js documentation for more details and options)
    <!-- load without autostart -->
    <script src=
    "https://host:1337/vorlon.max.autostartdisabled.js">
    </script>
    
    <!-- bind this to a button on command bar -->
    VORLON.Core.StartClientSide(
       "https://host:1337", 
       "default");
    
  • Last but not least: use at your own risk, contains small parts, choking hazard, swim between the flags. Not tested on animals, children or CRM 2011.
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #569: Migrate knowledgebase articles to Interactive Service Hub like a boss

If there is one bonus take away from the yesterday’s tip, it’s

existing KB functionality will soon be deprecated so it is advisable to transition to new KB as soon as possible.

So people started to ask, how to do that.

tl;dr

How to migrate KB article

Long version

Yes, some assembly is required. Good news, it’s not that difficult. As you may have noticed, I did develop some affection for the PowerShell as an ad-hoc developer’s tool.

Import-Module Microsoft.Xrm.Data.Powershell

$global:conn = Get-CrmConnection -InteractiveMode
  
# get the old articles
$articles = Get-CrmRecords `
   -EntityLogicalName kbarticle `
   -Fields * 
   
ForEach($a in $articles.CrmRecords) {

  # display the title
  $a.title

  # create the record
  $newrec = New-CrmRecord `
    -EntityLogicalName knowledgearticle `
    -Fields @{ "title" = $a.title; }

  # set the content if it exists
  if($a.content) {
    Set-CrmRecord `
     -EntityLogicalName knowledgearticle `
     -Id $newrec.Guid `
     -Fields @{"content" = $a.content}
  }
  
  # publish the article if it was published
  if($a.statecode -eq "Published") {
    Set-CrmRecord `
     -EntityLogicalName knowledgearticle `
     -Id $newrec.Guid `
     -Fields @{"statecode" = `
	   New-CrmOptionSetValue -Value 3}
  }
}   

Like a boss meme

 
VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #568: Disable new knowledgebase article notification

Mini Truckstop

Dynamics CRM TipperGotta love truckstops. Someone asks an interesting question, bunch of people send the answers in, all we need to do is to copy, link, verify, write some code, double-check, remove sensitive information, format, test, publish. Easy!

This time the question comes from none other than Julie “There is no place like home” Yack.

Question

Can someone tell me if I am missing something on this? It seems like a big risk and I’m not sure how to turn it off. I don’t think you can.

Admins of new orgs get the standard yellow notification above the command bar telling them go try ISH (Interactive Service Hub – t.j.). Users do not see this. Great. I don’t want them to see it. As admin, I want to decide if I want my users to go here or not. Many aspects to this, but at a minimum there’s training to worry about. But also, what the heck do I do if they go off on their own and make a whole new, unrelated knowledge base?

As a standard CRM user, I have access to traditional knowledge base. When I go here, I get this pretty yellow bar notification that there’s a new way to do this, click here and go make magic. How do I stop this from happening? Don’t all default roles have access to this?

This is from a new org, no customizations, user with only CSR role assigned. I can’t have random customer service rep making these decisions.
New KB notification

Discussion

Anonymous-who-knows-the-answer-#1: Making an SDK call to set ShowKBArticleDeprecationNotification = 0 on the OrganizationBase table will disable the banner from showing. https://msdn.microsoft.com/en-us/library/gg328408.aspx

Gayan “Not Daddy” Perera: Thanks, this disables the notification for the article area but not the main “Show how the interactive service hub can make you more productive. Experience it now”. Is there another flag that can disable that main message?

Anonymous-who-knows-the-answer-#2: Unfortunately there is no way to disable that message currently. We understand it is not an easy way but considering we are trying to move customers off the existing KB functionality to new one introduced in Ara, it’s a trade off we made. Please understand that the existing KB functionality will soon be deprecated so it is advisable to transition to new KB as soon as possible.

“Codeless” solution

For those who are interested in applying this setting with the minimal efforts and without writing any code, here is PowerShell snippet that will accomplish the task. (Note: you will need PowerShell module for Dynamics CRM Organization Data)

Import-Module Microsoft.Xrm.Data.Powershell

$global:conn = Get-CrmConnection -InteractiveMode
  
# get the orgs
$orgs = Get-CrmRecords `
   -EntityLogicalName organization `
   -Fields showkbarticledeprecationnotification

# there is only one, in fact
$org = $orgs.CrmRecords[0]

# display current setting
$org.showkbarticledeprecationnotification
 
# supress notification
Set-CrmRecord -conn $conn `
   -EntityLogicalName organization `
   -Id $settings.CrmRecords[0].organizationid `
   -Fields @{ `
   "showkbarticledeprecationnotification" = $false}
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #567: Tipster guide to Dynamics CRM 2016 New Knowledge Base Articles

Friday is the name of the day and another video is ready to be consumed. Dynamics CRM 2016 introduces new Knowledge Management capabilities, that include a new WYSWIG editor, the ability to delay publishing, article expiration, and much more. In this video we walk you though a tour of the new Knowledge Articles.

Give us your feedback, all of it: good, bad, and ugly, I’m sure we can take it. Suggest new topics either in comments or by sending your ideas to jar@crmtipoftheday.com.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Tweet about this on TwitterShare on FacebookShare on Google+

Tip #566: Constants in the workflow

Some might say that this tip is trivial but I was surprised myself when a very seasoned and knowledgeable user asked me how to use constants in the workflow.

They wanted to push an estimated close date for all open opportunities one month forward to account for the festive season that has just ended (for most people, anyway) and at the same time to bump the estimated value by 5% to account for the inflation.

For dates, use of constants is very clear – just use operator Set to, set the duration using dropdowns and select before or after (i.e. subtract or add). For money and numeric fields it is less obvious: do not use any of the fields but simply supply a constant as a default value.
Enter constants in the workflow

The end result looks like this:
Workflow update using constants

Set the workflow to be called on demand and then select multiple records and run the workflow. If you have hundreds of records that wouldn’t fit on one or two pages, you may want to consider some automation, like MSCRMWorkflowRunner or Bulk Workflow Tool for XRM Toolbox.

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Tweet about this on TwitterShare on FacebookShare on Google+