环境:MSCRM3.0 

 

在代码中使用系统默认的实体没有问题,

而使用自定义的实体,就产生异常“Server was unable to process request”

使用默认实体的代码:

                    QueryByAttribute query = new QueryByAttribute();

                    query.ColumnSet = new AllColumns();

                    query.EntityName = EntityName.contact.ToString();

                    query.Attributes = new string[] { "accountid" };

                    query.Values = new string[] { "{F0DCD12F-2734-DC11-8A94-000C297D4C1B}" };

                    BusinessEntityCollection retrieved = m_service.RetrieveMultiple(query);

使用自定义实体的代码:

                    QueryByAttribute query = new QueryByAttribute();

                    query.ColumnSet = new AllColumns();

                    query.EntityName = EntityName.new_job.ToString();

                    query.Attributes = new string[] { "new_workflowid" };

                    query.Values = new string[] { "{109B9B98-B339-DC11-B151-000C297D4C1B}" };

                    BusinessEntityCollection retrieved = m_service.RetrieveMultiple(query);

在最后一句产生异常“Server was unable to process request”。

问题解决:
原来是“new_workflowid"用错了,对应的关系schema不是这个名字。
要在实体的属性中确认使用的Schema名字存在。