- Problem evaluating entityname in callouts.
- Posted by CGoodyear on December 21st, 2006
I have some PostCreateCallouts that are working fine, but I would like
to know why in some cases I am unable to evaluate entitytypecode using
the EntityName enum provided in the framework? I have posted the code
I am using below. I have PostCreate callout methods for several
different entities, so I need a way to determine what callout method to
call on PostCreate. If I use a switch statement that evaluates the
entityTypeCode in the CalloutEntityContext, none of my case statements
seem to work unless I use the object's actual numeric EntityTypeCode.
If I try to use the enum, none of my methods are ever called (I have
commented out my attempts at using the enum). The only case where I
was successful in using the enum is with the account object. Has
anyone else experienced this, or does anyone know why this might be
happening? I'd rather use the enum values if I can. Thanks.
Here is the code I am using:
public override void PostCreate(CalloutUserContext userContext,
CalloutEntityContext entityContext, String postImageEntityXml)
{
try
{
//get a dynamic entity to represent the xml string
DynamicEntity entity = DeserializeDe(postImageEntityXml);
switch(entityContext.EntityTypeCode)
{
case (int)EntityName.account:
UpdateUnregisteredAccount(entity);
break;
case 1088://(int)CrmSdk.EntityName.salesorder:
UpdateSalesOrderName(entity);
break;
case 1089: //(int)EntityName.salesorderdetail:
ProcessOrderDetail(entity);
break;
case 10002: //(int) EntityName.new_project:
UpdateProjectID(entity);
break;
}
}
}
- Posted by Michael Höhne on December 21st, 2006
Hi Christine,
You cannot use the EntityName enumeration to compare against the entity type
code. The reason why it is usually working for the account entity is that
the account has an entity type code of 1 and the account is the first value
in the enumeration, thus also having a value of 1. To make it work the
EntityName enumeration would have to be declared like this:
enum EntityName {
account = 1,
contact = 2,
...
salesorder = 1088,
salesorderdetail = 1089,
...
new_project = 10002,
...
}
While that's possible in .NET, I doubt that SOAP can handle it. An
enumeration in an XML schema is a list of string values, so your proxy
classes will contain a enum like this:
enum EntityName {
account,
...
contact,
...
salesorder,
salesorderdetail,
...
new_project,
...
}
As there're no explicit integer values assigned, .NET uses 1 for account
(which accidentally is the same as the account's entity type code), 2 for
the next entity, 3 for the following and so on. salesorder may be the 69th
and salesorder the 70th entity in the enum, so .NET will use 69 and 70. You
new_project entity may be the 102nd value in the enum and .NET will use 102
as the integer value. Again, there's no relationship between the EntityName
enumeration and the entity type code.
You can safely use the entity type codes of the built-in entities
(everything < 10000). You need to be careful when using custom entities as
the entity type code may vary from system to system. You should use the
MetadataService to retrieve the appropriate type code on startup to obtain
the correct code for your custom entities.
--
Michael
Web: http://www.stunnware.com/crm2
Feed: http://www.stunnware.com/crm2/atom.aspx
Custom Lookup Dialog: http://www.stunnware.com/crm2/?area=customLookup
----------------------------------------------------------
"CGoodyear" <cgoodyear@gmail.com> schrieb im Newsbeitrag
news:1166740790.238890.36060@42g2000cwt.googlegrou ps.com...
- Evaluating email tracking (Windows CRM) by Simon Porter
- Hide button New:<entityname> (Windows CRM) by Bertil
- Evaluating CRM 3 (Windows CRM) by Chubbly Geezer
- (OT) Evaluating Broadband (Software & Applications) by Nunya Bizniss
- Help with evaluating used printer (Printers) by tempgal

