Showing posts with label CRM. Show all posts
Showing posts with label CRM. Show all posts

Thursday, 6 November 2014

Change the "Filter on" to all on the Activity Associated views

When we want to see all activities from an account the default value is "next 30 days".

If you want to change the default value there no easy way to do so. One the things it's change it by JavaScript.

Create a new JavaScript web resource and add this code to it:

 //default the Activities 'Filter on' to 'All'  
 function filterAllActivities() {  
   document.getElementById("navActivities").onclick = function () {  
     Mscrm.Details.loadArea(this, "areaActivities");  
     document.getElementById("areaActivitiesFrame").onload = function () {  
       var entityName = Xrm.Page.data.entity.getEntityName();  
       var entity = entityName.charAt(0).toUpperCase() + entityName.substr(1);  
       var doc = this.contentWindow.document;  
       var filterOn = doc.getElementById("crmGrid_" + entity + "_ActivityPointers_datefilter");  
       filterOn.value = "All";  
       var evt = document.createEvent("HTMLEvents");  
       evt.initEvent("change", false, true);  
       filterOn.dispatchEvent(evt);  
     };  
   };  
 }

Add this new JavaScript web resource library to the form properties (from the entity you want exemple: account, case, opportunity, etc), add an event handler in the form "OnLoad" and call the function "filterAllActivities"

Save and publish.

Monday, 3 November 2014

XML validation error when importing solution

Last week I was trying to import a manage solution into a new Microsoft dynamics CRM 2013 organization and I get the following error:

"The import file is invalid. XSD validation failed with the following error: 'The 'distinct' attribute is not declared."

After digging around the customization XML file from the solution, I found out that one of the user of my company build some custom charts and put the distinct property  into an attribute inside the fetchXML tag.



We contacted the Microsoft CRM support team and asked if it were possible to have a distinct property associated with the attribute tag. After a couple of days this was the reply from them:

I've confirmed internally that using the distinct property at attribute level on fetchXML is not allowed, as proved by the XSD validation schema you got.

On Dynamics CRM SDK we have some FetchXML queries that contains this property and it might be possible that the SDK will be changed to show the correct data that can be used.

We apologize for the situation caused by this, and we suggest you to move the distinct property to fetch tag and to not be used on attribute tag.

The solution to this problem:
  •      Unzip the solution zip file.
  •      Open the customizations.xml file.
  •      Remove or put the distinct= ”true” (only the ones that used with an attribute) into the fetch tag.

  •    Save the customizations.xml file.
  •    Delete the original XML in the zip file and add this new customizations.xml.
  •    Import solution.


Thursday, 30 October 2014

IOrganizationService

What is IOrganizationService?

Is the web service that accesses data and metadata for your organization. 

Why do I need a IOrganizationService?

You need IOrganizationService when you want to work with data in our Microsoft Dynamics CRM system. The methods available are:
  • -          Create (Create a record of an entity)
  • -          Retrieve (Retrieve a record of an entity)
  • -          RetrieveMultiple ( Retrieve a collection of records of an entity. This can be used with query expression or fetch XML)
  • -          Update (Update a record of an entity)
  • -          Delete (Delete a record of an entity)
  • -          Associate (Create a link between two records)
  • -          Disassociate (Delete a link between two records)
  • -          Execute (Execute a process. The must common is workflows, imports and detect duplicates)


How can I get IOrganizationService?

To get the organization service you need 3 thing:
  • -          User (username of a valid user on the CRM organization)
  • -          Password (valid password for the user)
  • -          Uri (You can get the organization service Uri in your Dynamics CRM system. Go to Settings à Customizations à Developer Resources.)


How can I use it on code?

Need a reference to the microsoft.xrm.sdk.dll from the SDK

C#
//organization url  
 IServiceManagement<IOrganizationService> orgServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(“Uri”));  
 //Put Credentials  
       AuthenticationCredentials authCredentials = new AuthenticationCredentials();  
       authCredentials.ClientCredentials.UserName.UserName = “user”;  
       authCredentials.ClientCredentials.UserName.Password = “password”;  
 AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);  
 //connection to CRM  
 OrganizationServiceProxy Service = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);  
       Service.EnableProxyTypes();  
       IOrganizationService _service = Service;