Archive

Archive for the ‘Uncategorized’ Category

Dynamics 365 – Error while sending mail on behalf of another user

Recently one of my users complained that they could not send mails on behalf of another users.

Unable to send email on behalf of another user

Issue was because of missing privilege and a setting at actual user, whom the other user trying to send on behalf of

Reason and fix:

To explain this better, I have 2 Users in my system

  • ‘Aruna’ : Having ‘Salesperson’ security role
  • ‘Rajeev’: Having ‘System Administrator’ security role

Issue coming up when ‘Aruna’ trying to send email as ‘Rajeev’ (i.e., Email.From=’Rajeev’)

To allow ‘Aruna’ send email as ‘Rajeev’ below 2 conditions has to be met

  • Provide ‘Send Email as Another User’ privilege to Aruna’s ‘Salesperson’ Security Role

Security Role - Send email as another user

  • Actual User (i.e., Rajeev) should enable ‘Select whether users can send email for you‘ option in his Personal Settings.

Personal Options - Other users can send email

🙂

ADX Web Site Compilation Error – The type ‘System.Object’ is defined in an assembly that is not referenced.

Recently while compiling my ADX web site, I was getting below compilation exception from all my .ascx (Views) files.

Compiler Error Message: CS0012: The type ‘System.Object’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

Issue was bit strange as I already had “System.Runtime’ dll referred in the website

Fix:

  • Open the Web.config file and add below tag inside the <compilation> tag

<assemblies>

<add assembly=”System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” />

</assemblies>

  • Your <compilation> tag should look as below

<compilation debug=”true” targetFramework=”4.5″>

<assemblies>

<add assembly=”System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” />

</assemblies>

</compilation>

Note:

  • If your <compilation> tag already had <add assembly=”…”> tags, add only <add assembly=”System.Runtime…> tag to the existing tags.

🙂

Categories: ADX, CRM, Uncategorized Tags: ,

Solution Import Failures / Publish Customizations Failures – Dynamics 365

February 12, 2017 3 comments

Recently we upgraded our organizations to Dynamics 365 and we were getting solution import failure while moving solutions between organizations.

Below are different kind of error messages popped up.

  • Getting Dependency Calculation There was an error calculating dependencies for this component. Missing component id {0}
  • Failure trying to associate it with CustomControlDefaultConfig
  • Can’t insert duplicate key for an entity

Reason:

  • In our case the root cause for all these import failures was “customcontroldefaultconfig” component with Custom entities.
  • If there is any orphan record exists in “CustomControlDefaultConfigBase” table it would cause solution import failure or ‘Publish Customizations’ error.
  • The issue seems a product issue and got fixed in Service Update 5 of CRM 8.1.0 but resurfacing again in Dynamics 365.

Prevention Tip:

  • If you are adding an entity to your solution, always add ‘Primary key’ field
    • In the source environment open the Solution being imported
    • Open each Entity and expand Fields
    • Make sure that every entity has its “Primary Key” added to the solution.

solution-add-primary-key-field-of-entity

Fix:

CRM On-Premise

  • Check if any orphan records in CustomControlDefaultConfigBase tabel. (Use below queries)
    • SELECT * FROM CustomControlDefaultConfigBase WHERE PrimaryEntityTypeCode NOT IN (SELECT ObjectTypeCode FROM Entity)
  • Note: before continuing, a backup database is recommended.
  • Delete from the Target environment the CustomControlDefaultConfig records with orphaned Object Type Codes:
    • DELETE FROM CustomControlDefaultConfigBase WHERE PrimaryEntityTypeCode NOT IN (SELECT ObjectTypeCode FROM Entity)

CRM On-line

  • Create console application to delete the orphan record in CustomControlDefaultConfigBase using CRM SDK
  • Refer this URL for code.

🙂

CRM Record “Email a Link” feature not working

February 8, 2017 Leave a comment

Recently few of our CRM users complained OOB “Email a Link” not working.

email-link

Reason:

  • Machines default “Email” App was set to “Chrome”

email-settings

Fix:

  • Change default “Email” App to “Mail” or “Outlook” client

 

email-settings-set-to-mail-client

🙂

Categories: CRM, Uncategorized Tags: , ,

New field ‘Sort Date’ in Activity Pointer entity – Dynamics 365

January 26, 2017 Leave a comment

A new field ‘Sort Date’ (Schema Name – sortdate) has been added to the ‘Activity Pointer’ entity to control the sorting of the Activities.

sort-date-activities

Limitation with earlier CRM versions:

  • To display a list of activities and order them by date, we can only use the common date attributes like ‘Created on’ or ‘Modified on’ defined in the activitypointer entity.
  • What if you have to sort Email activities by ‘Sent On’ attribute rather than the modifiedon attribute value?

How ‘Sort Date’ Solves This:

  • With ‘Sort Date’ attribute, we can control how activities are sorted by desired date.
  • By default, the ‘Sort Date’ attribute value is null.
  • Set the ‘Sort date’ attribute value using a workflow or a plugin with required Date value (For example, set ‘Sort Date’ with ‘Sent On’ value in case of Emails) and use that in views.

🙂

Create a child record by copying mapping fields data from Parent – Using CRM SDK

January 26, 2017 Leave a comment

Let’s take the OOB Account and Contact related entities.

Whenever we click ‘Add New Contact’ button from the ‘Associated view’ of ‘Account’ form, all the mapping fields data would be copied to ‘New Contact’ form.

Account:

account-form

New Contact Form:

create-contact

This is native CRM behavior, to copy the content from Parent to Child record, using the Relationship ‘Mappings’ to avoid the overhead of manual data entry on child record.

account-and-contact-mappings

What If we have to create a Contact from a console application using CRM SDK and achieve the same behavior?  ‘InitializeFromRequest’ is the answer.

Steps to use ‘InitializeFromRequest’:

  • Instantiate the ‘InitializeFromRequest’
  • Set the Target as ‘Contact’
  • Set the ‘EntityMoniker’ as the reference of parent ‘Account’ which you would want to copy the data from
  • Execute the ‘InitializeFromRequest’
  • From the ‘InitializeFromResponse’, read the Contact object with copied data from Account (**Contact would not be created in CRM at this point**)
  • Fill the other attributes
  • Create the Contact

Source Code:

InitializeFromRequest initialize = new InitializeFromRequest();

// Set the target entity (i.e.,Contact)
initialize.TargetEntityName = “contact”;

// Create the EntityMoniker of Source (i.e.,Account)
initialize.EntityMoniker = new EntityReference(“account”, new Guid(“D4CBEE74-B5E3-E611-8109-C4346BDD8041”));

// Execute the request
InitializeFromResponse initialized = (InitializeFromResponse)orgService.Execute(initialize);

// Read Intitialized entity (i.e.,Contact with copied attributes from Account)
if (initialized.Entity != null)
{
// Get entContact from the response
Entity entContact = initialized.Entity;

// Set the additional attributes of the Contact
entContact.Attributes.Add(“firstname”, “Rajeev”);
entContact.Attributes.Add(“lastname”, “Pentyala”);

// Create a new contact
orgService.Create(entContact);
}

If you put the debugger and watch the ‘initialized.Entity’ you would see the populated fields.

initialized-entity-contact

Post execution of this code, a new Contact would get created with copied data from Account.

contact-form

🙂

Switch Business Process Flow using Jscript based on CRM form’s field value

April 30, 2016 1 comment

Recently we got a requirement to switch the Business process on Case form based on ‘Case Origin’.

Its easily achievable using Jscript “setActiveProcess” method.

Xrm.Page.data.process.setActiveProcess(processId, callbackFunction);

  • processId‘ is the GUID of the ‘Business Process Flow’. You can copy the GUID from URL.
  • Go to ‘Settings –> Processes’ open the ‘Business Process Flow’ and copy the value from ‘id’ parameter, between %7b %7d
Copy Business Process ID

Copy Business Process ID

  • ‘callbackFunction’ is your custom JScript function name which gets triggered post ‘Business Process’ switch.

Below are the scenario and steps.

  • I have 3 Active Business Process Flows on my ‘Case’ entity.
Active Business Process Flows

Active Business Process Flows

  • ‘Business Process Flows’ are Security Role Based, so if my user has access to all 3 ‘Business Process Flows’, he can switch the process using ‘Switch Process’option.
Swicth Business Process

Swicth Business Process

Multiple Business Process Flows

Multiple Business Process Flows

  • In my scenario, ’Switch Process’ should happen based on ‘Case Origin’ field.
    • If ‘Case Origin’= Phone; Set “Business Process1”
    • If ‘Case Origin’= Email; Set “Business Process2”
  • Below is the script

function onload() {
// If not new Case form
if (Xrm.Page.ui.getFormType() != 1) {
// Read Origin Option text
var origin = Xrm.Page.data.entity.attributes.get(“caseorigincode”);

if (origin && origin.getText()) {
var caseOrigin = origin.getText();

// Get Business process flow id
var processFlow1Id = “6CD44946-0DC5-47E3-9B62-6D7309254710”;
var processFlow2Id = “0B3A94CD-CD43-4F49-A9A3-93C4AC684CFA”;

// Get Current Active Process Id
var activeProcess = Xrm.Page.data.process.getActiveProcess();
var currProcessId = activeProcess.getId();

if (caseOrigin.toLowerCase() == “phone”) {
// Change the process only if current Active Process not the Target one
if (currProcessId.toLowerCase() != processFlow1Id.toLowerCase()) {
// Switch to the “Process Flow 1”
Xrm.Page.data.process.setActiveProcess(processFlow1Id, myCallBack);
}
} else if (caseOrigin.toLowerCase() == “email”) {
// Change the process only if current Active Process not the Target one
if (currProcessId.toLowerCase() != processFlow2Id.toLowerCase()) {
// Switch to the “Process Flow 2”
Xrm.Page.data.process.setActiveProcess(processFlow2Id, myCallBack);
}
}
}
}
}

// Call back function post Process flow switch
function myCallBack(response) {
if (response == “success”) {
alert(“BPF changed !!!”);
// Save the form
Xrm.Page.data.entity.save();
}
else {
alert(“Error changing BPF!!!”);
}
}

How do I use the script?

  • Copy the script and create a new ‘Web resource’ in CRM and add to ‘Case’ form.
  • Register ‘onload()’ function on form onload event.
Register onload event - Case form

Register onload event – Case form

  • Publish the Customizations.
  • Open the Case record and based on ‘Case origin’ system auto switches to the Business process Flow.
New Business Process Selected

New Business Process Selected

Key points on multiple ‘Business process flows’:

  • You can have up to 10 active business process flows per entity.
  • You can associate business process flows with security roles so that only people with those security roles can see or use them.
  • In case of multiple Active ‘Business process flows’, the first activated business process flow in that list is the one that will be applied by default.
  • Each record can have only one business process flow at a time.
  • If someone’s security roles do not allow them to use a specific business process flow, the current business process flow will be visible, but disabled.

🙂