views:

5918

answers:

5

I have created a custom entity in MS CRM 4.0 and am trying to update a couple of the attributes via a custom worflow in .Net. I have read through several of the forums and blog posts and am still confused on how to access the custom entity and update some of their attributes.

I created a custom entity to replace how CRM was doing allotments as our company has some specific business rules that CRM wasn't doing. When a task is completed on an incident I want to update an attribute in the custom entity with the task duration. Any help would be greatly appreciated.

Thanks

+4  A: 

When using the CRM web service in a custom workflow, you'll need to use DynamicEntity objects. The workflow context webservice is just an ICrmService so it doesn't know about your specific customizations. There's a pretty sample here: http://www.stunnware.com/crm2/topic.aspx?id=CustomWorkflowActivity

I imagine you could also add the CRM web services as a web reference to your workflow project. Then you'd have strongly types objects for your custom entities. I've never done this for my custom workflows, but it works for other custom apps accessing CRM.

Mikeyb
This works. I have done it in practice. You have to have the web reference to retrieve (and update) the dynamic data but use static entities for the input and output parameters.
Jeff Davis
A: 

It's very easy and you dont'have to use DynamicEntity. You have to go to Settings -> Customization -> Download WSDL. Take the wsdl and use it in your project. Now you have all your custom entities strongly typed. All you have to do is to write something like this:

Guid entityId = getEntityId();
new_yourCustomEntity entity = new new_yourCustomEntity();
entity.new_yourCustomEntityid = entityId;
entity.new_customProperty = "value";
CrmService crmService = new CrmService();
crmService.Update(entity);
Ricibald
A: 

Hi, Jan

Maybe what you really mean is Custom Workflow Activity? This involves writing your own .NET class to add functionality to the standard CRM WF in form of new step types. If what you want to do is just to update an attribute you don't really need this, even if it is on a custom entity. The Update record step does just this and allows dynamic values (coming from other entities) to be specified.

Hope it helps

Daniel

dsabater
A: 

I've been trying to implement a plugin which will add up sub-totals of related entities, and place the total in a field on the current entity. I can't do it with a workflow, since if the product line item changes, I'd need the sub-total before and after the event.

1 Product has many Product Line Items

Product.total cost = sum(sub-total of each Product Line Item)

Can anyone fill me in on how to sum the costs of all related product line items and put that in the total cost of the product?

This should be it's own question.
Jeff Davis
A: 

Thanks. It was quite informative.But i also want to add to this. One can easily retrieve the MS CRM entities including the customized one using web services. For this the following web services needs to be referenced from visual studio .Net.

URL: http://:/MSCRMServices/2007/AD/CrmDiscoveryService.asmx?WSDL Web Reference Name: CrmSdk.Discovery

Eliza

eliza