[UWP] The certificate specified is not valid for signing

While developing UWP app setting up certificate is required in order to deploy app on other machine. On destination machine user need to install and trust this certificate. This is PowerShell script I used for generating valid certificate for signing UWP app.

 $HT = @{
  Subject = 'goran.lazic';
  KeyLength = 2048;
  HashAlgorithm = 'SHA256';
  KeyUsage = 'DigitalSignature';
  KeyExportPolicy = 'Exportable';
  KeySpec = 'Signature';
  NotAfter = (Get-Date).AddYears(15) ;
  TextExtension = @('2.5.29.37={text}1.3.6.1.5.5.7.3.3', '2.5.29.19={text}Subject Type:End Entity');
  CertStoreLocation = 'Cert:\CurrentUser\My'
}

New-SelfSignedCertificate @HT

Note that Subject should be name of publisher from application manifest file. Certificate from an example has validity period for next 15 years.
After creating new certificate export it and add into UWP application solution. After, just select that certificate in packaging setting in appxmanifest.

Global search in UI – missing entity?

In custom model driven app created on Dynamics 365 9.1 on-premises, several entities configured for global search were not visible. For an example, in global search I setup Notes entity, but it is not visible under new app which runs under new UI.

Global search entities are configured under Administration -> System Settings -> section Set up Quick Find.

Current setup looks like:

On image below it is displayed all entities available in Global search filter in legacy Dyn365 app and new custom model driven app.

Even if Notes are used on some existing entities in model driven app like Quotes and Invoices it is not presented in search filter list. Problem here was that Note entity is not included in app components.

After Note entity is included in app components, it is also visible under global search filter:

[Dyn 365] Could not load file or assembly ‘file:///C:\Program Files\Dynamics 365\server\bin\assembly\****.dll’ or one of its dependencies. Access is denied.

I’ve setup clean on premise installation of Dynamics 365 v9.0. When I tried to create new workflow I got this error:

Could not load file or assembly ‘file:///C:\Program Files\Dynamics 365\server\bin\assembly\Microsoft.Dynamics.Service.Plugins.dll’ or one of its dependencies. Access is denied.

Issue was that folder was not inheriting security permissions from C:\Program Files\Dynamics 365\Server\bin. Right click on assembly folder -> Properties -> Security tab  -> Advanced -> Click on Enable inheritance button.
After that I needed to restart IIS. Works fine then!

[CRM] How to publish entity using SDK?

If we did some changes on Account entity using SDK, we can very simply publish them. There is PublishXmlRequest message provided by SDK.

// Publish Account entity
string accountEntityXml = "Account";

PublishXmlRequest publishxmlrequest = new PublishXmlRequest
{
ParameterXml = String.Format(accountEntityXml)
};

_orgService.Execute(publishxmlrequest);

We can use ParameterXml to define which solution component to publish in the request.

If we want to publish all customization we will use PublishAllXmlRequest.

PublishAllXmlRequest publishAllReq = new PublishAllXmlRequest();
_orgService.Execute(publishAllReq);

[CRM] Render email template – InstantiateTemplateRequest

I wanted to have step in workflow process where draft Email will be created using template.

There are two out of the box options regarding Email step in workflow. We can create draft email with specified body and subject. Other option is to send email using some workflow.

In order to create draft email with rendered template I created custom workflow activity which will execute InstantiateTemplateRequest, and for a result return rendered subject and message body.

This is a part of workflow activity:

InstantiateTemplateRequest instTemplateReq = new InstantiateTemplateRequest
{
    TemplateId = templateId,
    ObjectId = contactId,
    ObjectType = "contact"
};
InstantiateTemplateResponse instTemplateResp = (InstantiateTemplateResponse)service.Execute(instTemplateReq);

Three parameters are sent, Template Id (Guid of email template), Contact Id as Object Id and contact Object Type. Here is rendered template of Contact type.

After executing request we need to pull out result details from InstantiateTemplateResponse object:

Entity template = instTemplateResp.EntityCollection.Entities[0];
 if (template != null && template.Attributes.Contains("description"))
 {
    TemplateSubject.Set(executionContext, template.Attributes["subject"].ToString());
    TemplateDescription.Set(executionContext, template.Attributes["description"].ToString());
 }

In last workflow step I added Create new email step where Subject and Description are applied on new email record.

[CRM] Activity Party Types

I was looking for Email senders/receivers in [ActivityPartyBase] table. To identify what Email entity field is related to some ActivityParty we are using column [ParticipationTypeMask] in table [ActivityPartyBase]. Here are possible values for this column:

Activity party type Value Description
Sender 1 Specifies the sender.
ToRecipient 2 Specifies the recipient in the To field.
CCRecipient 3 Specifies the recipient in the Cc field.
BccRecipient 4 Specifies the recipient in the Bcc field.
RequiredAttendee 5 Specifies a required attendee.
OptionalAttendee 6 Specifies an optional attendee.
Organizer 7 Specifies the activity organizer.
Regarding 8 Specifies the regarding item.
Owner 9 Specifies the activity owner.
Resource 10 Specifies a resource.
Customer 11 Specifies a customer.
Partner 12 Specifies a partner.

[CRM] Default entities and status codes

Status and Status reason are both optionsets.  Option set have an int value and a text value.  The text value is meta data and the int value is held in the database on the database field.

Default entities have two status values

State

  • Active = 0
  • Inactive = 1

Status reason have different default values

Status Reason

  • Active = 1
  • Inactive = 2

 

Taken from Hosk’s blog

[CRM Email Router] Incoming Status: Failure – The account does not have permission to impersonate the requested user.

This errors occurred when I configured incoming email profile in Email router 2015. To resolve this I had to configure exchange impersonation in Exchange 2013 for email router account.

Exchange Impersonation enables a caller to impersonate a given user account. This enables the caller to perform operations by using the permissions that are associated with the impersonated account, instead of the permissions that are associated with the caller’s account.

This is command that should be executed within Exchange power shell console:

New-ManagementRoleAssignment -Name:”CRM mail account” -Role:ApplicationImpersonation -User:emailrouter

MSDN link

[CRM, Email router] System.UnauthorizedAccessException: Access to the path ‘C:\Program Files\Microsoft CRM Email\Service\Microsoft.Crm.Tools.EmailAgent.xml’ is denied.

After fresh installation of CRM email router 2015 (07.00.0000.3543) I setup all necessary configuration. It is connected to CRM organization but I got following error:

#16192 – The Email Router service could not run the service main background thread. The Email Router service cannot continue and will now shut down. System.Configuration.ConfigurationErrorsException: System information was not specified in the Email Router service configuration file. The Email Router service cannot continue and will now shut down. —> System.UnauthorizedAccessException: Access to the path ‘C:\Program Files\Microsoft CRM Email\Service\Microsoft.Crm.Tools.EmailAgent.xml’ is denied.

After short investigation I figured out that email router service and CRM installations have different version. Actually CRM has already upgraded to version 07.0.0002.0053 (0.2 Update installed). So solution was to upgrade email router to the same version. Everything works OK then 🙂

[CRM] A managed solution cannot overwrite the Attribute component with Id= ….

My task was to install CRM 2015 solution on another CRM machine. When I tried this I got following error:

A managed solution cannot overwrite the Attribute component with Id=c75c4cc7-0fc2-e611-80bf-0050568ab8eb
which has an unmanaged base instance. The most likely scenario for this error is that an unmanaged solution
has installed a new unmanaged Attribute component on the target system, and now a managed solution from the
same publisher is trying to install that same Attribute component as managed. This will cause an invalid
layering of solutions on the target system and is not allowed.

This error was related with one of custom entities in my solution. First I checked which attribute was causing the problem. This can be found with executing following script on CRM Organization database:

SELECT *
FROM AttributeLogicalView
WHERE AttributeId = ‘c75c4cc7-0fc2-e611-80bf-0050568ab8eb’

I found online few solutions (source):

  • Remove attribute from managed solution exported from source environment, or
  • Remove attribute from unmanaged (in this case default) solution in target environment

In my case this was’t an option since attribute that causing error was ProcessId, out of the box field in CRM. If you try to delete it you will get an error: Only custom fields can be deleted.

Root of issues was with different version of CRM 2015 installations. On Source CRM was installed CRM 2015 with update 0.2. And from this version solution is generated. On Target CRM was only installed 2015 – without any updates.

So conclusion was simple, before importing CRM solution install Update 0.2 on target environment 🙂