Hi,
There are several options for writing logs
1. Create log in event viewer
2. Create log in file
3. Create log in entity log
Here is an example of writing log in event viewer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace WriteToEventLog {
class Program {
static void Main(string[] args) {
string eventViewerName = "EventViewerName";
string sourceName = "Project name";
string message = "My Message";
if (!EventLog.SourceExists(sourceName))
EventLog.CreateEventSource(sourceName, eventViewerName);
EventLog.WriteEntry(sourceName, message);
EventLog.WriteEntry(sourceName, message, EventLogEntryType.Warning, 1100);
EventLog.WriteEntry(sourceName, message, EventLogEntryType.Error,45454);
}
}
}
Thanks
Rami Heleg.
This site helps you to develop in the easy way Microsoft Dynamics CRM. Microsoft Dynamics CRM includes many examples to develop for Microsoft Dynamics CRM.
Wednesday, September 30, 2009
Friday, September 25, 2009
Problem:
Running server-side code developments under CRM Server folder get Error 401 – Unauthorized.
This is a problem I've seen several times.
if you try to run the same code not under CRM folder and it works fine here is the Solution:
To solve this error need to make change in Microsoft CRM 4.0 web config:
What to add:

Thanks,
Rami Heleg
Running server-side code developments under CRM Server folder get Error 401 – Unauthorized.
This is a problem I've seen several times.
if you try to run the same code not under CRM folder and it works fine here is the Solution:
To solve this error need to make change in Microsoft CRM 4.0 web config:
What to add:
Thanks,
Rami Heleg
CRM Screens freeze- Stuck
Try to open CRM Form usually edit.aspx page with a few iframes.
in some cases screen Stuck.
The reason for that is internet explorer Settings.
The default connection for internet explorer is two. It means the main form request data + one of the iframes then other iframes wait.. this problem Causes CRM to be freeze.
Solution:
Change the default values:
Open register page:
1. Go to start - > run and Type regedit:
2. Define MaxConnectionsPer1_0Server and MaxConnectionsPerServer like the following example
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings] MaxConnectionsPer1_0Server = dword: 0000000a
MaxConnectionsPerServer = dword: 0000000a
Thanks,
Rami Heleg
in some cases screen Stuck.
The reason for that is internet explorer Settings.
The default connection for internet explorer is two. It means the main form request data + one of the iframes then other iframes wait.. this problem Causes CRM to be freeze.
Solution:
Change the default values:
Open register page:
1. Go to start - > run and Type regedit:
2. Define MaxConnectionsPer1_0Server and MaxConnectionsPerServer like the following example
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings] MaxConnectionsPer1_0Server = dword: 0000000a
MaxConnectionsPerServer = dword: 0000000a
Thanks,
Rami Heleg
Tuesday, September 22, 2009
Update entity Based Micorost CRM SDK
Hi,
This example used to update record in crm 3.0 and crm 4.0 based SDK
//Create crm service
CrmService pService = new CrmService(); // optional to set url
// define entity + fields. mandatory field is key
incident oInc = new incident();
oInc.incidentid = new Key();
oInc.incidentid.Value = new Guid("guid");
oInc.title="my title"
pService.Update(oInc);
update Can get specific entity for instance contact, incident or dynamic entity.
all type of BusinessEntity.
thanks,
Rami Heleg
This example used to update record in crm 3.0 and crm 4.0 based SDK
//Create crm service
CrmService pService = new CrmService(); // optional to set url
// define entity + fields. mandatory field is key
incident oInc = new incident();
oInc.incidentid = new Key();
oInc.incidentid.Value = new Guid("guid");
oInc.title="my title"
pService.Update(oInc);
update Can get specific entity for instance contact, incident or dynamic entity.
all type of BusinessEntity.
thanks,
Rami Heleg
Monday, September 21, 2009
Create Entity Based Microsoft CRM SDK
Hi,
this example used to create a new record in crm 4,3 based CRM SDK.
//Create CRM Service
CrmService pService = new CrmService(); // optional to set url BusinessEntity
//Define entity and add values..
contact oContact = new contact();
oContact.firstname = "Rami";
oContact.lastname = "Heleg";
//Run method to create the entity.
Guid guid = pService.Create(entity);
//guid of the new record.
Thanks,
Rami Heleg
this example used to create a new record in crm 4,3 based CRM SDK.
//Create CRM Service
CrmService pService = new CrmService(); // optional to set url BusinessEntity
//Define entity and add values..
contact oContact = new contact();
oContact.firstname = "Rami";
oContact.lastname = "Heleg";
//Run method to create the entity.
Guid guid = pService.Create(entity);
//guid of the new record.
Thanks,
Rami Heleg
Using SDK to delete entity record via Dynamic entity
This Example help to delete record using SDK function.
DeleteRequest request = new DeleteRequest();
TargetDeleteDynamic target = new TargetDeleteDynamic();
target.EntityName = entityTypeName;
target.EntityId = instanceID;
request.Target = target;
pservice.Execute(request);
Enjoy,
Rami Heleg
DeleteRequest request = new DeleteRequest();
TargetDeleteDynamic target = new TargetDeleteDynamic();
target.EntityName = entityTypeName;
target.EntityId = instanceID;
request.Target = target;
pservice.Execute(request);
Enjoy,
Rami Heleg
RetrieveMultipleResponse - Query example.
Example of query on server side.
//Create Condition.. can be many conditions + type of operator
ConditionExpression[] conditions = new ConditionExpression[1];
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = fullname;
condition.Operator = ConditionOperator.Equal;
condition.Values = new object[] { "Rami Heleg" };
conditions[i] = condition;
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = conditions;
QueryExpression query = new QueryExpression();
//Entity name
query.EntityName = "contact";
//allow to define specific columns
query.ColumnSet = new AllColumns();
query.Criteria = filter;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.ReturnDynamicEntities = false;
request.Query= query ;
//run Query
RetrieveMultipleResponse response = (RetrieveMultipleResponse)pService.Execute(service, request);
//Result
response.BusinessEntityCollection.BusinessEntities;
Thanks,
Rami Heleg
//Create Condition.. can be many conditions + type of operator
ConditionExpression[] conditions = new ConditionExpression[1];
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = fullname;
condition.Operator = ConditionOperator.Equal;
condition.Values = new object[] { "Rami Heleg" };
conditions[i] = condition;
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = conditions;
QueryExpression query = new QueryExpression();
//Entity name
query.EntityName = "contact";
//allow to define specific columns
query.ColumnSet = new AllColumns();
query.Criteria = filter;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.ReturnDynamicEntities = false;
request.Query= query ;
//run Query
RetrieveMultipleResponse response = (RetrieveMultipleResponse)pService.Execute(service, request);
//Result
response.BusinessEntityCollection.BusinessEntities;
Thanks,
Rami Heleg
Subscribe to:
Posts (Atom)