Saturday, October 31, 2009

Fetch Query



Fetch is an option to ask CRM information's.

To get information from CRM we can
1. Ask directly from DB
2. SDK for BE
3. Fetch.

To build fetch the best option is to build the fetch from Advanced find, see attached picture to get the fetch:
Write: javascript:alert(advFind.FetchXml)
Here are two examples to for query:

Sunday, October 11, 2009

How to pass information from steps 10 (pre) and post(50) in CRM Plug In

Here is an example how to pass information between pre and post ( 10- 50).

Object context contain SharedVariables.

Set values in 10 like this example code:
context.SharedVariables["myvalue"] = “rami Heleg”;

Read value in 50 ( post) like this example code:
string name = context.SharedVariables["status"].ToString();


Can be used for status win or Lose... or for closing incident and needs "IncidentResolution".

Thanks,
Rami Heleg

How to create CRM Plug In in CRM 4.0

1. Create a new project from type “class Library”

2. Create a new class with name : “MyExample”

3. Paste this code in new class.


using System;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;

namespace MyExample{

public class AuditPlugin: IPlugin
{
public void Execute(IPluginExecutionContext context)
{
//start my code.
}
}
}

4. Compile and now the dll is ready to install with register tool.

Thanks,
Rami Heleg

Wednesday, October 7, 2009

Example of using XElement to create xml.

Hi,

Here is an example of using XElement to create xml.

The example is building xml, root, nodes and attributes.

The example is very very simple to make it in 2-3 rows

Requirement: Framework 3.5


using System.Xml.Linq;

example:

XElement element = new XElement("root");
element.Add(new XElement("MyNode",
new XAttribute("attr1", "value1"),
new XAttribute("attr2", "value2")));

element.Add(new XElement("MyNode2",
new XAttribute("attr1", "value3"),
new XAttribute("attr2", "value4")));
//xml is ready
element.ToString()

thanks
Rami Heleg,

Sunday, October 4, 2009

How to prevent SQL Timeout expired in Microsoft Dynamics CRM:

One of the problems when working with CRM and SQL is when making a complex Select/Query CRM get SQL time out.

The solution is define timeout in register.

1. Open regedit ( start - > write ( regedit) ) and press ok

2. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM

3. Add DWORD name OLEDBTimeout with value 86400 ( 24 hours) select decimal

4. Add DWORD name ExtendedTimeout with value 1000000. The maximum value can be 2,147,483,647 and the default value is 30 seconds

This changes in register should fix the SQL timeout.

Thanks,
Rami Heleg.

Thursday, October 1, 2009

What is the property deletionstatecode ?

How can I remove from crm database record and not with delete command?

Each entity in CRM 4.0 includes two tables, base and extension.
In base table the columns are the same. statecode,guid,createdon...

One of the columns is deletationstatecode.

Deletionstatecode define if record is live in CRM or should be deleted.

Deletionstatecode = 0 record exist and live in CRM
Deletionstatecode = 2 record should e removed.

One of the services responsoble to remove all the record where deletionstatecode =2.
The if I need to remove many records in crm direct from database change the deletionstatecode to 2 and record will be removed after job finished.

Thanks,
Rami Heleg