Dynamics CRM 2011 SDK remove attribute with dependencies - dynamics-crm-2011

I'm having troubles with removing the attribute of entity which have dependencies from SDK.
To remove an attribute I need:
RetrieveAttribute
RetrieveDependenciesForDeleteRequest
DeleteRelationshipRequest
and finally DeleteAttributeRequest
I would be appreciated for any advise about the plan above or sample code.
I couldn't find example at msdn so far.

So it appears that the RetrieveDependenciesForDeleteRequest is telling you that you have to delete a relationship before you can delete the attribute; and you are doing so.
I expect that this is a look-up attribute?
Is it visible in the entity form?
You won't be able to delete the attribute as long as the entity form has a dependency on it.

Related

How to create attribute from Intelligent cubes

We have Intelligent Cubes in my Microstrategy project. I would like to create attribute from Developer. I have connected to my project source and right clicked on Schema objects -> Attributes . I don't see any Create Attribute button.I tried to create filter/Metric/Prompt for every thing its expecting attribute in Public objects->Attributes folder. How can I add a new attribute in the folder to create filter/Metric/Prompt
please refer to this document. there are many ways to create attribute. hope its helping
https://www2.microstrategy.com/producthelp/10.4/ProjectDesignGuide/WebHelp/Lang_1033/Content/ProjectDesign/Creating_attributes.htm

Unmanaged installation and Entities data

I have unmanaged solution installed in un online prod environnement and I want to install a new version of this solution in the same environnement, my question is that if I do that, what will happen to my data entities as I don't want to lose my data from the environnement?
Thanks in advance,
The data in the base tables will be not be altered when importing a new solution.
It will be the entity definition.
If a new attribute has been created for an entity which is set to Business Required then a null value will be held until a user opens the form which will require that value to be supplied before the record can be updated.
+1 to Stefan's answer. I will also add that unmanaged solutions will never delete any data. It is always additive, so if you remove an attribute from an entity in your solution in dev, it will not be removed when you import it into another environment. You'll need to manually track these removals and remove them post solution deployment.

Update Metadata Property of an Attribute in CRM 4.0

Can I update IsValidForAdvancedFind property for an attribute in metadata in a supported way. At present I have an attribute which I dont want to show in advanced find view.
Please help!
The following link contains all you need to know about making an attribute none – searchable
http://mscrmtools.wordpress.com/tools/searchable-property-attribute-updater/
There are several ways to update IsValidForAdvancedFind attribute but not every attribute of any entity can be updated. Can you please share which attribute from which entity do you want to update?

How to find unused/non-dependent fields of any entity in CRM 2011?

I am trying to identify unused or non-dependent fields of any entity in Microsoft Dynamics CRM 2011. By unused or non-dependent i mean the field that is not used in any of the entity forms.
I have googled to find on the same topic but couldn't get the desired results. One link that i have come across also doesn't address this problem:
Finding unused CRM fields
First I should note that just checking if a field is not on a form does not mean it is not being used somewhere. There is a chance if you have a third party integration, or other logic running on an entity that it could be updating hidden fields. If you're unsure if there is data stored for an attribute you can do a retrieve request where your condition is that the attribute is not null. If nothing comes back then there is no data stored for that attribute.
Assuming that is already clear, what you'd want to do is utilize Dynamics CRM's Dependency Tracking to check for dependencies of individual attributes.
Here's the full article on Dependency Tracking for CRM 2011: http://msdn.microsoft.com/en-us/library/gg309749.aspx
The request that sounds most like what you're looking for is the RetrieveDependentComponentsRequest. This request seems to be the closest match according to what you're looking for and per the documentation:
Returns a list of dependencies for solution components that directly depend on a solution component.
For example, when you use this message for a global option set solution component, dependency records for solution components representing any option set attributes that reference the global option set solution component are returned.
When you use this message for the solution component record for the account entity, dependency records for all of the solution components representing attributes, views, and forms used for that entity are returned.
The basic steps to accomplish what you're looking for would then be:
Execute a RetrieveEntityRequest to retrieve all the attributes for a particular entity
For each attribute in the response, execute a RetreiveDependentComponentsRequest where you set the ObjectId to the MetadataId of the attribute, and the ComponentType to be 2 (attribute).
Parse the EntityCollection property on the response to see if any of the dependencies have a ComponentType of 24 (form).

lazy loading issue for attached entities

I've changed my DAL codebase from ObjectContext (EF4) to DbContext (EF5).
My problem is when i attach an entity to DbSet and access a navigation property i got null instead of an object, however in my old code (ObjectContext case) it was returning me object and no null.
I can solve issue by explicit loading but it's a lot of pain to find all codes that uses navigation properties of attached entities.
Is there a clear solution?
Thanks

Resources