How to disable caching using XrmDataContext in Dynamics CRM 4.0? - caching

We are using the Advanced Developer Extension against Dynamics CRM 4.0. We have generated the entities and the Xrm context using CrmSvcUtil.
What we need to do is disable the built in caching that the context uses as it is returning incorrect results, but I've been unable to find out how to do this - any ideas ?
Thanks
Matt

Take a look at these links
http://arens.ws/wordpress/?p=54
http://community.adxstudio.com/Default.aspx?DN=d589dc6c-b2bf-4ae1-a8ca-06ac55f2a177&topic=40f3987f-9600-4a75-84f8-1dcffcfbd875&page=1
http://msdn.microsoft.com/en-us/library/gg398020.aspx

Ok - found the answer at this site
CacheManager.GetBaseCache().Remove("adxdependency:crm:entity:[entityschemaname]");
Obviously replace [entityschemaname] with the schema name of the entity that you want to remove from the cache :-)

Related

Date Operations in Entity Framework Core

I am using LINQ to talk to Dynamics CRM. I have found the DbFunctions class in the docs. But when I go to the definition it has NO methods. I want the DateDiffYear method, but I can find no samples online and it simply does not appear to be present in the reflected code?
OK, the docs are USELESS. You need to install EntityFrameworkCore.SqlServer for this to appear.
Thanks for being my rubber duck again, Stack Overflow!!!!

Publish a Dynamics CRM Theme programatically?

Is it possible to publish a Dynamics CRM Theme programatically ? I've tried setting the "isdefaulttheme" flag to true but this causes an exception.
I can't see an SDK message to do it - but it can be done from the CRM UI so there must be a way somehow :-)
You are looking for the PublishThemeRequest.
https://learn.microsoft.com/en-us/dotnet/api/microsoft.crm.sdk.messages.publishthemerequest?view=dynamics-general-ce-9
PublishThemeRequest request = new PublishThemeRequest();
request.Target = new EntityReference(Theme.EntityLogicalName, defTheme.Id);
service.Execute(request);
Ben's answer is perfect. You can also do the same using WebAPI if you need to:
POST /CRMORG/api/data/v8.2/themes(11111111-1111-1111-1111-111111111111)/Microsoft.Dynamics.CRM.PublishTheme()

Removing an EntityRelationship by its guid

when saving a modified account form on a MS Dynamics CRM 2015 on-premise installation I recently get an error:
Dependency Calculation
The dependent component EntityRelationship (Id=5288430f-7abf-e511-80cd-000d3a203473) does not exist. Failure trying to associate it with SystemForm (Id=e284b20f-a66d-4019-9a96-83d6ce65847e) as a dependency. Missing dependency lookup type = PrimaryKeyLookup.
This message is not quite useful to me to fix the problem.
If I want to fix it, where should you look for ID "5288430f-7abf-e511-80cd-000d3a203473" and which toold would you use?
You could try the CRM Metadata Browser. This is included in the tools folder in the CRM SDK that you can download for free. It is a managed solution that you have to install into CRM. Once installed you can use it to view information about your entities and their attributes
MSDN Page for Metadata Browser
Select your entity; This will then list all the attributes that belong to the selected entity, in this case Account
You can then look through all the relationships and look for the Metadata ID property of the record. For example, here is the ID for the Primary Contact relationship
You will probably have to examine all these relationships manually to find a match though.
Hope this helps

Dynamics CreateEntityRequest - assign entity to a display area

I'm trying to create a new entity and have it appear in the 'My Finances' and 'Personal Assets' areas.
I am able to create the entity without problems using CreateEntityRequest.
If I create the entity manually I get a list of the variuos areas where I can display the entity.
How can I do the same thing programmatically?
Thanks,
David
You'd have to manipulate the SiteMap to do that; that's not something that's done in the metadata of the entity itself.
I was able do get this to work using the Microsoft.Crm.Sdk.IsvReadiness.SupportingItems.SiteMap class that comes with the SDK in conjunction with ExportXmlRequest and ImportXmlRequest.
Thanks,
David

Update Custom Entities in MS CRM 4.0 via Custom Workflow

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
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.
Choosing Dynamic Entities over WSDL in favour is always the better choice.
When you develop a piece of code, you are more flexible with your classes. You could use your piece of software in different contexts for different systems. That's the reason Dynamic Entities were invented.
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);
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

Resources