Category: CRM 2016

Response type ‘token’ is not enabled for the application

Response type ‘token’ is not enabled for the application


Recently I faced problem when I was trying to build client-side app with CRM and Azure.

I was able to login to my APP and adal.js successfully acquired a token for my webApi and injected it into a request.

Then token acquisition for webApi stopped working with error:

“response_type ‘token’ is not enabled for the application”

Here is the steps that resolved my problem.

Note: If we’re building client-side app, so we need to enable Implicit flow from the application manifest.

How?

1. Select the Configure tab of your application’s entry in the Azure Management Portal.

2. Using the Manage Manifest button in the drawer, download the manifest file for the application and save it to your computer.

2

3. Open the manifest file with a text editor. Search for the oauth2AllowImplicitFlow property. By default it is set to false; change it to true and save the file.

3

4.Using the Manage Manifest button, upload the updated manifest file.

4

Logout and Login with again with you app and it’ll work like a charm.

For more info about OAuth Flow please refer below links

Looking at the Different OAuth2 Flows Supported in AzureAD for Office 365 APIs

v2.0 Protocols – SPAs using the implicit flow

An Introduction to OAuth 2

Hope it’ll help someone.

Thanks for visiting my blog.

Update FetchXml and Grid layout of Entity View using C# in CRM

Update FetchXml and Grid layout of Entity View using C# in CRM

In this post, I am going to tell you how we can update Entity view programmatically using c#.

Before starting let’s cover entity view and their query types.

What is Entity View ?

Entity views are special SavedQuery that retrieve data by using a specific filter. They also contain information about how the data in the view should be displayed in the application.

An Entity view is different from a UserQuery. A user query, called a Saved view in the application, is owned by an individual user, can be assigned and shared with other users, and can be viewed by other users depending on the query’s access privileges.

Let’s create a new view in account entity i.e. My Custom Accounts

1

4

Here is default Grid Layout and FetchXml of this view

2

5.PNG

Now we write some code for getting fetchXml and layoutXml for this view.

 

QueryExpression qe = new QueryExpression(“savedquery“);
qe.Criteria.AddCondition(“returnedtypecode”, ConditionOperator.Equal, “account“);
qe.Criteria.AddCondition(“name”, ConditionOperator.Equal, “My Custom Accounts“);
qe.ColumnSet = new ColumnSet(true);
var viewData= _service.RetrieveMultiple(qe);

 

For our demo purpose we’re trying to add Account Number in FetchXml.

You can also add filter or some complex query which we want to add but can’t add using Advanced find.

 

//Update fetchxml of view
XmlDocument xml1 = new XmlDocument();
xml1.LoadXml(viewData.Entities[0][“fetchxml”].ToString());
XmlNode entityNode= xml1.SelectSingleNode(“//entity”);
var newAttrnode= xml1.CreateElement(“attribute”);
var nameAttribute = xml1.CreateAttribute(“name”);
nameAttribute.Value = “accountnumber”;
newAttrnode.Attributes.Append(nameAttribute);
entityNode.AppendChild(newAttrnode);
dar.Entities[0][“fetchxml”] = xml1.OuterXml;

 

Using below code ,we’re trying to add accountnumber column in our view grid.

 

//Update Gridxml of view
XmlDocument gridxml = new XmlDocument();
gridxml.LoadXml(viewData.Entities[0][“layoutxml”].ToString());
XmlNode rowNode = gridxml.SelectSingleNode(“//row”);
var newrowAttrnode = gridxml.CreateElement(“cell”);
var accountname = gridxml.CreateAttribute(“name”);
accountname.Value = “accountnumber”;
newrowAttrnode.Attributes.Append(accountname);
var width = gridxml.CreateAttribute(“width”);
width.Value = “150”;
newrowAttrnode.Attributes.Append(width);
rowNode.AppendChild(newrowAttrnode);
dar.Entities[0][“layoutxml”] = gridxml.OuterXml;
_service.Update(dar.Entities[0]);

 

//Publish Account Entity
PublishXmlRequest puxml = new PublishXmlRequest()
{
ParameterXml = “<importexportxml><entities><entity>account</entity></entities></importexportxml>”
};
_service.Execute(puxml);

 

That’s it, our custom view successfully updated with Account Number Column. 🙂

7

6

Thanks for visiting my blog.

Do some creative stuff in CRM  !!!  🙂

 

 

 

 

QueryExpression with a paging cookie

QueryExpression with a paging cookie

Query expressions are used in methods that retrieve more than one record, such as the IOrganizationService.RetrieveMultiple method, in messages that perform an operation on a result set specified by a query expression, such as BulkDeleteRequest and when the ID for a specific record is not known.

You can use the paging cookie feature to make paging in an application faster for large datasets. The feature is available in both FetchXML and QueryExpression queries. When you use the paging cookie feature when querying a set of records, the result contains a value for the paging cookie. To improve system performance, you can then pass that value when you retrieve the next set of records.

QueryExpression and FetchXML use different formats for their paging cookies. If you convert from one query format to the other by using theQueryExpressionToFetchXmlRequest message or the FetchXmlToQueryExpressionRequest message, the paging cookie value is ignored. In addition, if you request nonconsecutive pages, the paging cookie value is ignored.

 // Query using the paging cookie.
 // Define the paging attributes.
 // The number of records per page to retrieve.
 int queryCount = 3;
 
 // Initialize the page number.
 int pageNumber = 1;
 
 // Initialize the number of records.
 int recordCount = 0;
 
 // Define the condition expression for retrieving records.
 ConditionExpression pagecondition = new ConditionExpression();
 pagecondition.AttributeName = "parentaccountid";
 pagecondition.Operator = ConditionOperator.Equal;
 pagecondition.Values.Add(_parentAccountId);

 // Define the order expression to retrieve the records.
 OrderExpression order = new OrderExpression();
 order.AttributeName = "name";
 order.OrderType = OrderType.Ascending;

 // Create the query expression and add condition.
 QueryExpression pagequery = new QueryExpression();
 pagequery.EntityName = "account";
 pagequery.Criteria.AddCondition(pagecondition);
 pagequery.Orders.Add(order);
 pagequery.ColumnSet.AddColumns("name", "emailaddress1"); 

 // Assign the pageinfo properties to the query expression.
 pagequery.PageInfo = new PagingInfo();
 pagequery.PageInfo.Count = queryCount;
 pagequery.PageInfo.PageNumber = pageNumber;

 // The current paging cookie. When retrieving the first page, 
 // pagingCookie should be null.
 pagequery.PageInfo.PagingCookie = null;
 Console.WriteLine("Retrieving sample account records in pages...\n");
 Console.WriteLine("#\tAccount Name\t\tEmail Address"); 
 
 while (true)
 {
 // Retrieve the page.
 EntityCollection results = _serviceProxy.RetrieveMultiple(pagequery);
 if (results.Entities != null)
 {
 // Retrieve all records from the result set.
 foreach (Account acct in results.Entities)
 {
 Console.WriteLine("{0}.\t{1}\t{2}", ++recordCount, acct.Name,
 acct.EMailAddress1);
 }
 }

 // Check for more records, if it returns true.
 if (results.MoreRecords)
 {
 Console.WriteLine("\n****************\nPage number {0}\n****************", pagequery.PageInfo.PageNumber);
 Console.WriteLine("#\tAccount Name\t\tEmail Address");

 // Increment the page number to retrieve the next page.
 pagequery.PageInfo.PageNumber++;
 
 // Set the paging cookie to the paging cookie returned from current results.
 pagequery.PageInfo.PagingCookie = results.PagingCookie;
 }
 else
 {
 // If no more records are in the result nodes, exit the loop.
 break;
 }
 }
How to change Publisher Prefix

How to change Publisher Prefix

What we do if we need to change prefix  for already created entity in CRM dynamics. Today i’ll explain how we can do this without creating entity and all other solution component from skretch. I’ll explain step by step with screenshots.

 

First we create a new solution in CRM dynamics and also create and add new publisher for this solution.
Solution Name – Sample Solution For 2015
Publisher Name- Aman Kothari
Publisher Pregix – am15

s1

 

For our demo purpose i just created  a new entity  i.e. am15_student

s2

s3

After that we export it as unmanaged solution.

s4

 

s5

we are open it into winrar or any other zip extract tool (without extracting into folder). It contains three xml files i.e.
[Content_Types].xml
customization.xml
solution.xml

we need to change only the highlighted files.

s6

s7

let’s create one more publisher in CRM i.e. Admin CRM 2015 and prefix name is am2016.

we’ll change Student entity from am15_student to am2016_student

s8

First we open solution.xml file in VS. after that we replace unique name , lozalized name, customized prefix name of solution with new one.
E.g. am15 to am2016 , Aman Kothari to Admin CRM 2016 etc.

 

s9

s10

after changing it we need to save xml file.

s12

after updating solution.xml file, customization.xml file needs modification .

In cusomization.xml we replaced prefix for entities, attributes, relationships, formxml of forms etc from am15_ to am2016_  and save it.

 

s13

s14

Now our zip solution is ready with new publisher name and prefix let’s import this file after delete the first solution.( because solution name is same so it conflicts with old solution components).

 

s16

Solution imports successfully. 🙂

s17

So this is how you can change the schema of unmanaged solution component.

Thank you for visiting my blog 🙂

 

What’s new in CRM dynamics for developers

What’s new in CRM dynamics for developers

Hi fellas this is my first blog and i am really excited about it.Today i am gonna tell you about what is new in CRM dynamics 2016.

1.CRM Online features now available for on-premises organizations

New features that were added to Microsoft Dynamics CRM Online 2015 Update 1 are now available for on-premises organizations. One exception is the integration with Parature which is only available for CRM Online. For a summary of new features included in that release, see What’s new for Microsoft Dynamics CRM Online 2015 Update 1

2.Web API

The Web API will make it easier to create applications across a wide variety of platforms, devices, and programming languages. The Web API provides parity with the existing organization service (SOAP endpoint). You will be able to do anything using the Web API that you can do using the organization service, with a few differences. You won’t have to download any Microsoft Dynamics CRM SDK assemblies. You can perform all operations using HTTP requests with the Web API located at [organization uri]/api/data/v8.0/.

for more info please visit at https://msdn.microsoft.com/en-us/library/gg309589.aspx#BKMK_WebAPI

webapi1

Discovery service

To maintain parity with the Discovery service on the SOAP endpoint, they’ve added a Discovery service to the Web API. This service enables you to determine, at run-time, the organizations that the signed-in user belongs to. You can retrieve information about those organizations like the organization service URL, the CRM release version, and more. A new feature of the Web API Discovery service is the ability to filter the returned list of organizations by using OData filter parameters. The Discovery service is supported by all CRM deployment types. More information: Discover the URL for your organization using the Web API

webapi1

Form script support for keypress events and auto-completion feature

Use the new getValue method to retrieve the value of a control when the user presses keys in a number or text control. You can use this value to configure interactive experiences, such as data validation as user types in a field, by configuring function handlers for keypress events using the newKeypress methods. In addition, you can use the new Auto-completion methods to configure the auto-completion feature for text controls in forms. These new methods aren’t supported for CRM for phones or CRM for tablets.

For more Info please visit at
https://msdn.microsoft.com/en-us/library/mt607648.aspx

Web resources and IFRAMEs

The ability to create web resources and IFRAMEs for use with CRM for tablets is now fully supported in all CRM for tablets forms: iOS, Android, and Windows 10. Previously, this was only available as a preview feature. More information:Create web resources and IFrame content for use with the CRM for tablets client

Form script support for new custom controls

Use new custom controls to configure a visually modern and richer experience for your users in CRM for phones and CRM for tablets. More information:TechNet: Use the form editor

The new custom controls support all the existing client APIs supported by the CRM controls, except for the Auto-completion methods, getValue,Keypress methods and Lookup control methods and events. For the complete list of client APIs supported by CRM controls, see Xrm.Page.ui control (client-side reference).

Open records in CRM mobile client with a URL

The new application handler protocol in Microsoft Dynamics CRM 2016 enables you to use URLs to directly open records in CRM for phones and CRM for tablets. It also lets you open an empty form for creating an entity record. To use this feature, you have to install the CRM for phones or CRM for tablets application on your mobile device. More information: Open forms, views, and dashboards in CRM mobile client with a URL

Knowledge management enhancements

The CRM Service module gets a boost in this release with the addition of powerful knowledge management capabilities. In addition to rich text, the newKnowledgeArticle entity supports multimedia data like pictures and videos. Articles have a lifecycle where they proceed through a publishing workflow.

Discover the answers to your questions using full text searches of knowledge base records for topics and products using theFullTextSearchKnowledgeArticleRequest message. This message provides systematic access to a keyword based search index of the article content. Use this message to access that search content and provide search results to customers and partners.

To support the knowledge management capability, new privileges named Publish Knowledge Articles and Approve Knowledge Articles were added. The Customer Service Representative and Customer Service Manager roles have these privileges, and a new Knowledge Manager role has been added.

For the CRM web client, the client-side form programming API has been updated to include additional properties in the object returned from thegetSelectedResult function call. All other client APIs and events, which were supported by the knowledge base search control in the Microsoft Dynamics CRM 2015 release, continue to be supported.

For the new interactive service hub client, only the getSearchQuery and setSearchQuery methods are supported for the knowledge base search control.

For more information about the client-side APIs supported by knowledge base search control, see Knowledge base search control (client-side reference). For more information about knowledge management, see Knowledge management entities.

Solution enhancements

Previously, when an entity was added to a solution and that solution was exported, the entity and all of its assets were exported in that solution. This included attributes, forms, views, relationships, visualizations, and any other assets packaged with the entity. All objects were exported regardless of whether the developer actually wanted to ship the object. This process potentially carried dependencies or modified unintended objects on the target deployment.

A new solution capability is now available that allows a developer or other application customizer to create solution patches that contain subcomponents of entities, as compared to publishing the entire entity and all of its assets. The original solution and multiple released patches can be rolled-up at a later time into an updated version of the original solution, which then can replace the original solution.

solution

Upload and manage document templates

You can now create document templates (Microsoft Excel or Microsoft Word) to have a standardized representation of your CRM data. These templates can be used by your team members to generate Excel or Word documents with up-to-date CRM data for analysis and reporting purposes. Use the SDK to programmatically upload and manage document templates.

More information: Upload and manage document templates in CRM

XRM Tooling controls now support OAuth authentication and connection strings

Microsoft.Xrm.Tooling.Connector is the primary interface to CRM for all tooling and Unified Service Desk operations. It is also provided as part of the Microsoft Dynamics CRM SDK to developers who want to build CRM connected Windows applications. Developers can use this updated API to allow the OAuth 2 protocol to be used to authenticate with CRM web services. Adding OAuth enables multi-factor authentication for improved security and access to CRM.

XRM tooling now also supports connection strings, which allow for the use of SQL-like connection strings in the CrmServiceClient class.

More information: Build Windows client applications using the XRM tools

New entities in CRM 2016

The following table lists new entities included in this release.

Schema name Display name Description
KnowledgeArticle Knowledge Article Describes articles that are organizational knowledge for internal and external use. More information:Work with knowledge articles in Dynamics CRM
KnowledgeArticleIncident Knowledge Article Incident Contains the associations between a knowledge article and incident. More information: Work with knowledge articles in Dynamics CRM
KnowledgeArticleViews Knowledge Article Views Tracks the number of times an article is viewed per day. More information: Work with knowledge articles in Dynamics CRM
LanguageLocale Language Contains information about the supported languages for translating a knowledge article. More information: Work with knowledge articles in Dynamics CRM

New messages in CRM 2016

The following table lists new messages included in this release.

Request class name Web API action Description More information
CloneAsPatchRequest CloneAsPatch Action Creates a solution patch from a managed or unmanaged solution. Create patches to simplify solution updates
CloneAsSolutionRequest CloneAsSolution Action Creates a new copy of an unmanaged solution that contains the original solution plus all of its patches. Create patches to simplify solution updates
CreateKnowledgeArticleTranslationRequest CreateKnowledgeArticleTranslation Action Creates a translation of a knowledge article record. Create a knowledge article translation
CreateKnowledgeArticleVersionRequest CreateKnowledgeArticleVersion Action Creates a major or minor version of a knowledge article record. Create major and minor versions of a knowledge article
DeleteAndPromoteRequest DeleteAndPromote Action Replaces a managed solution plus all of its patches. Create patches to simplify solution updates
FullTextSearchKnowledgeArticleRequest N/A Performs a full-text search on knowledge articles in CRM using the specified search text. Search knowledge articles using full-text search
IncrementKnowledgeArticleViewCountRequest N/A Increments the per day view count of a knowledge article record. Increment knowledge article view count
SetProcessRequest SetProcess Action Sets the process that associates with a given target entity.
UpdateSolutionComponentRequest UpdateSolutionComponent Action Updates a component in an unmanaged solution. Package and distribute extensions using solutions

for more info visit at

https://msdn.microsoft.com/en-us/library/gg309589.aspx

 

Software Development Kit for Microsoft Dynamics CRM Online and CRM 2016 (on-premises)

https://msdn.microsoft.com/en-us/library/hh547453.aspx