Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Wednesday, July 22, 2015

HowTo: Avoid simultaneous execution of 2 instances of same workflow for a record

Let’s imagine that you (as a consultant) use waiting workflows (booo, I know that waiting workflows are evil). But let’s imagine and you have a field on a record that is responsible for datetime till when workflow has to wait to proceed. Obviously that change of a datetime field should lead to change of workflow “waiting to proceed” time. But you can’t apply this change to workflow that is triggered already. So to complete the task you have to kill existing instance of a workflow and run new. This article describes custom workflow activity that does the trick.

Monday, November 04, 2013

Microsoft CRM 2013 - Integration with BingMaps: difference between OnPremise and Online instances

Difference I faced today is following – OnPremise instance has Bing Map api key field in System Settings but Online doesn’t.

OnPremise:
OnLine:
 

Sunday, October 27, 2013

Microsoft Dynamics CRM 2013: Actions walkthrough for .Net and JavaScript developers

I believe that almost every developer for Dynamics CRM faced with scenario when he/she had to invoke some complex logic on a server side, pass parameters and receive a response back. Before CRM 2013 we used workarounds similar to this one. Once Dynamics CRM 2013 was released we have got solution that would not require ‘magic’.

Thursday, December 20, 2012

MS CRM 2011: How to cancel/postpone Workfow Instance using C#

Today I had a task to cancel about 25k instances of the same workflow. Of course it was possible to create Advanced Find View and go through 100 pages cancelling all workflows on the page. But I’m too lazy and I know C# to do that manually.

Tuesday, November 13, 2012

Integrating CRM 2011 using SQL Integration Services 2012

I have already wrote similar article using SSIS 2008. Following article describes how to use the same functionality using new version of SSIS.

Monday, November 05, 2012

Friday, June 01, 2012

MS CRM 2011: CallerOrigin in plugins

Yesterday well-known MVP Tanguy Touzard, author of amazing tools for Dynamics CRM 4.0/2011 asked about CallerOrigin property in plugins for Dynamics CRM 2011. This property worked for CRM 4.0 and returned the source of plugin invocation (Application, AsyncService or WebService). I and Gayan suggested to use HttpContext class from System.Web namespace to check source.
 Today during debug of one plugin in QuickWatch window I have seen that CallerOrigin property is still in context but it is not property of IPluginExecutionContext:

Wednesday, May 30, 2012

MS CRM 2011: Strange error during sending of an email from plugin

I had scenario when my plugin based on some condition had to send an email. I developed plugin, deployed it to server and during the testing I have got quite strange error:

Monday, May 21, 2012

MS CRM 2011: Import of marketing list members using standard import with small extensions

Unfortunately at the moment it is impossible to import Marketing Lists Members to CRM with out-of-box import. My friend, former MVP and employee of Microsoft Artem Grunin provided good approach how to eliminate this problem with small customizations and plugin.

Sunday, May 20, 2012

MS CRM 2011: Data transferring between systems

I think a lot of developers faces with integration between systems. It could be connection between CRM and accounting systems. To track changes that appeared at CRM and should be transmitted to other system I use plugins but how to understand what was the source of this changes – user of CRM system or synchronization service – this is the question. I use following approach to solve this issue:

Friday, May 18, 2012

MS CRM 2011: Code which rechecks that N:N relation exists between 2 records

Sometimes in your code you have to recheck is relation between 2 records exist. I faced with the same issue and developed following code.

Saturday, February 11, 2012

Integrating CRM 2011 using SQL Integration Services (SSIS)

I read this article and decided to make something similar for CRM 2011. You can see results in this post.

Monday, August 29, 2011

CRM 4.0 - detach answered email from queue

One of my customers requested following functionality - detach email from queue when email is answered.

Solution consists of 2 parts - customization of email (addition of source email field and JavaScipt which will extract id of source email) and Plugin which will handle Send message.

Saturday, June 11, 2011

Rollup activities for custom entities in Microsoft Dynamics CRM 4.0

Everybody who works with Microsoft Dynamics CRM knows that it is possible to see activities for special entities like contact, account or opportunity but not for custom entities. I had task to develop such kind of functionality. I proposed easier solution - report but customer wanted to have all activities in standard grid.

Friday, June 10, 2011

CRM 4.0 - Error at the stage of creation of the task from plugin

Today I had task to develop plugin which depends on internal logic had to create the task. I used following code inside plugin:

ICrmService crmservice = context.CreateCrmService(false);
task _task = new task();
_task.subject = "Task Subject";

try
{
crmservice.Create(_task);
}
catch(SoapException e)
{
throw new Exception(e.Detail.InnerText);
}


When I tested plugin it threw non-descriptive "Generic SQL error". I switched on trace and found following description of an error:

Exception when executing non-query: insert into QueueItemBase(QueueId, OrganizationId, State, Status, ObjectId, ModifiedOn, Priority, CreatedBy, ObjectTypeCode, TimeZoneRuleVersionNumber, EnteredOn, Title, ModifiedBy, QueueItemId, DeletionStateCode, CreatedOn, UTCConversionTimeZoneCode) values ('00000000-0000-0000-0000-000000000000', '7b839df8-96ea-4ee0-85bf-967a5f9060ef', 0, 2, 'a6341e54-5693-e011-aa0e-000c29d64722', '06/10/2011 11:39:51', 1, 'e490fea9-a809-4f08-b79e-392b9355b9f1', 4212, 0, '06/10/2011 11:39:51', 'Subject', 'e490fea9-a809-4f08-b79e-392b9355b9f1', 'a7341e54-5693-e011-aa0e-000c29d64722', 0, '06/10/2011 11:39:51', 0) Exception: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "queue_entries". The conflict occurred in database "orgname_MSCRM", table "dbo.QueueBase", column 'QueueId'.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command)
at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate)
at Microsoft.Crm.BusinessEntities.BusinessProcessObject.ExecuteNonQuery(IDbCommand command, ISqlExecutionContext context)

The issue is when you use code ICrmService crmservice = context.CreateCrmService(false) and you don't fill ownerid field of activity this activity automatically is assigned to 'System' user and 'System' user doesn't has any queues (by default any standard user has 2 personal queues - Assigned and In Progress).

So the way out is to create ICrmService instance using code
ICrmService crmservice = context.CreateCrmService(true);
or fill ownerid field of activities.

Wednesday, January 19, 2011

CRM 4.0 - Assigning Case to Queue

I had the task to assign case (incident) to queue. MSDN has good sample. But this sample didn't solved my problem because in my case not in all situations item was assigned to "In Progress" queue of user. Following code solved my problem.


Thursday, September 16, 2010

Queues - plugin which shows the count of items inside queue

I developed the plugin to make it possible to see near the name of queue the total count of items inside it. But it doesn't work for Assigned and In-Progress (personal queues).

Thursday, August 26, 2010

Record Counter for Microsoft Dynamics CRM 4.0 - version 2.1

I published new version of record counter at the start of the year - http://a33ik.blogspot.com/2010/02/record-counter-for-microsoft-dynamics.html.

Users who used it told me about several errors. Now those error are fixed and you can download latest version here:


Also I changed the possibility to control the appearance of Record Counter line. This can be done in plugin registration tool. Registration option are shown below:

Execute step:


RetrieveMultiple step:

Thursday, June 17, 2010

Formatting datetime in workflows with custom workflow activity in Microsoft Dynamics CRM 4.0

I've found one weird thing in workflows - when you insert datetime value inside text field you can't format it. Result of such inserting:


Friday, May 28, 2010

How to bind CRM Data to GridView on custom ASP.Net page for Microsoft Dynamics CRM

I have seen this article one of my colleague Hassan Hussain. I've decided to use other approach to bind data to GridView on custom ASP.Net page - instead BusinessEntitiesCollection I used Fetch.