Wednesday, January 20, 2010

Making Description Field Required in Close Opportunity Dialog

This is unsupported customization, so be careful.

Open folder with your CRM website. Open SFA\opps subcatalog.

Thursday, January 07, 2010

Setting attribute description as a tooltip for a field in entities forms in Microsoft Dynamics CRM 4.0

There is simple way to set tooltip text for field on CRM form. You can do it with following script placed on OnLoad event handler of some CRM form:

crmForm.all.<field name>_c.title = 'Tooltip text';
crmForm.all.<field name>_d.title = 'Tooltip text';


It will be hard work to create detailed tooltips for all fields placed on form
using this script. I've decided to develop script which will set text of field's tooltip based on description of field in attribute customization form.

Tuesday, January 05, 2010

Handling Rollup message with plugins in Microsoft Dynamics CRM 4.0

There are no Rollup message in the list of supported message in SDK. Following trick will help developers to handle this message.



Open Microsoft SQL Server Management Studio, select your organization database in dropdown control, and execute following script:

Update SdkMessageFilter 
Set IsCustomProcessingStepAllowed = 1
Where SdkMessageId in
(Select SdkMessageId From SdkMessage Where Name = 'Rollup')


Now it is possible to register your plugins on rollup message. Open plugin registrator and check it:



First interesting thing I saw when I began to debug plugin is that both PrimaryEntityName and SecondaryEntityName are filled (PrimaryEntityName with entity you search - activitypointer, annotation, incident. e.t.c., SecondaryEntityName with entity from which you want to see related records - contact, account, e.t.c. - all combination can be found in SDK):



Next interesting I've found is content of InputParameters:

"Target" is the array of objects. First object is just string with parent entity record type name. Second object is instance of CrmMoniker class - contains parent entity type name and identifier of record. Third object is instance of QueryExpression class and it contains filters based on which records will be retrieved.
"RollupType" is additional marker what records will be retrieved - property of RollupType enumeration.



Next interesting thing was found OutputParameters property - BusinessEntityCollection - the result of RollupRequest - all entities that meet criterion passed in InputParameters property:



How can this feature be used by developers? In various ways... For example I will answer for myself on answer I was asked here - "Have You figured out how to catch the rollup message to count activities or cases related to an entity?" - now I know how to do it. Other way to use this feature - is to configure rollup filter as you want...

But remember - such customizations are unsupported!

Saturday, January 02, 2010

MVP award

I have been awarded Microsoft MVP - Dynamics CRM.
Thanks for my family, friends, colleagues and of course Microsoft.

You can see my MVP profile here: https://mvp.support.microsoft.com/profile/Andriy.Butenko

Tuesday, November 24, 2009

Clearing fields in Microsoft Dynamics CRM 4.0

I've used following code to clear fields (set properties of entities to null):

account acc = new account();
acc.accountid = new Key(new Guid("249FB2CF-31CD-DE11-AB59-005056B30605"));

Lookup lookup = new Lookup();
lookup.IsNull = true;
lookup.IsNullSpecified = true;

acc.primarycontactid = lookup;
crmservice.Update(acc);


This code works but there is more elegant and readable way to clear fields:

account acc = new account();
acc.accountid = new Key(new Guid("249FB2CF-31CD-DE11-AB59-005056B30605"));
acc.primarycontactid = Lookup.Null;
crmservice.Update(acc);


Similar approach also will work for CrmDateTime, CrmNumber, Picklist, Customer, CrmMoney, CrmFloat, CrmDecimal fields.

Tuesday, November 03, 2009

Custom workflow action which returns current DateTime value

Here is the code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Workflow.Activities;
using Microsoft.Crm.Workflow;
using System.Workflow.ComponentModel;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;
using Microsoft.Crm.SdkTypeProxy;

namespace CurrentDateTimeWorkflowStep
{
[CrmWorkflowActivity("Current Date Time", "Utiles")]
public class CurrentDateTime : SequenceActivity
{
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
Value = CrmDateTime.Now;

return base.Execute(executionContext);
}

public static DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(CrmDateTime), typeof(CurrentDateTime));

[CrmOutput("Value")]
public CrmDateTime Value
{
get
{
return (CrmDateTime)base.GetValue(ValueProperty);
}
set
{
base.SetValue(ValueProperty, value);
}
}
}
}


And here is the source project and built assembly.

Tuesday, October 20, 2009

showModalDialog and postbacks in custom aspx pages in Microsoft Dynamics CRM 4.0

I've developed a custom aspx dialogue page. It has button with postback and when this button is clicked - action is executed but new window is opened. Solution for this case is to add <base target="_self"/> tag under head tag.