Quantcast
Channel: Sam's Activities
Viewing all 3363 articles
Browse latest View live

Support to open an Entity form in a new Window in Dynamics CRM 2015 SP1

$
0
0

Introduction:

Every CRM update comes with a lot of goodies for both the developers and the end users, so Dynamics CRM 2015 SP1 was not different.

One of such feature is opening a record in a new window.

While most of you`ll think, what`s so great in this, we have been doing this since CRM 2011, or maybe even before that.

Well here the difference is, now this is available through CRM API.

Before finding out how to achieve this, let`s run down the memory lane, let`s start with CRM 2011 and understand how this functionality have evolved with every update from CRM 2011 to CRM 2015 SP1.

CRM 2011:

How do we used to open an entity record or simple, a record during CRM 2011 era?

We used to use the JavaScript functionality of window.open() to open up a record.

Syntax:

window.open(URL, name)

URL - server name + URL of the record

name – specifies where to open the window, i.e., on the same page or a new tab or a new window.

CRM 2013:

Now, comes the CRM 2013, complete overhauled design, with added features for developer.

It further simplified the way of opening a record, by providing us a parameterized function. This also ensured that it works across devices.

Syntax:

Xrm.Utility.openEntityForm(name, id, parameters)

name – Name of the entity, whose record we want to open.

id – GUID of the record to be opened, if passed null, it opens an empty record form.

parameters – parameters to be used on the form.

Though it simplified the process of opening a record by eliminating the need to create the URL, still it lacked in one component i.e., giving us the choice whether to open a record on the same page or in a new window.

Remember since CRM 2013, all navigation in CRM is in-place i.e it replaces the current page with the new URL that is requested.

Using the above piece of code to open a record, would very well open the record, but it would open on the same page itself, which was kind of annoying.

What if we want to open a record in a new window then? Well, we have to use the same conventional method i.e., window.open(). As a result this functionality could be achieved but not supported across devices.

CRM 2015 SP1:

Then, came CRM 2015 SP1 update, in this update the openEntityForm method has been enhanced further

It means the method is allowed to take in one more parameter, which on specifying defines where the record would open

Syntax:

Xrm.Utility.openEntityForm(name, id, parameters, options)

options – It`s optional.  It takes in an object in which we have to specify true or false, true means open in a new window and false means to open on the same page. If this parameter is not specified it defaults to false.

How to use this functionality?

First of all create an Object.

var options = {

openInNewWindow : true

};

Note: the property openInNewWindow cannot be replaced by any another name.

Xrm.Utility.openEntityForm(“account”, null, null, options)

The object just takes only one property currently, we cannot specify the height or width of the window to be opened. It by defaults take up the entire screen.

Conclusion:

  • Now, the records can be open in a new window.
  • Currently, we cannot define the size of the window to be opened.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementaion, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Support to open an Entity form in a new Window in Dynamics CRM 2015 SP1 appeared first on Inogic Blog.


How to apply script on Header fields and BPF fields

$
0
0

CRM 2013 now allows java script coding on header fields as well as BPF fields. Sometimes we come across with the requirement where we need to write script on the fields existing in the business process flow and not on the form. Same with the fields on header of any form.

When a form displays a business process flow control in the header, additional controls gets added for each attribute that is been displayed in that BPF. These controls hold unique names like:header_process_<attribute name>. So using this control we can write script around these fields.

The Controls displayed in the form header are also accessible and hold unique name like:header_<attribute name>.

We can perform all those operations that we can perform on the attribute added on the form. Below we have mentioned some of the sample scripts around such fields.

  • Show/Hide field

We can also show/hide the fields from the BPF same like we do for the other form attributes. Below we have hidden the field based on the value selected on the form.

img1

We can simply use below line of code to show/hide the field from the BPF.

Xrm.Page.getControl(“header_process_parentcontactid”).setVisible(false);

You can use below line of code to show/hide the field from the Header.

Xrm.Page.getControl(“header_leadsourcecode”).setVisible(false);

  • Make the field Read only

The field will be read only after applying script on the BPF controls.

img2

Below is a line of code where we have disabled the control from the BPF.

//Check if the control exist on the form

if (Xrm.Page.getControl(“header_process_parentcontactid”) != null) {

//Set the control disabled

Xrm.Page.getControl(“header_process_parentcontactid”).setDisabled(true);

}

The same script you can use to apply to the header fields.

//Check if the control exist on the form

if (Xrm.Page.getControl(“header_leadsourcecode”) != null) {

//Set the control disabled

Xrm.Page.getControl(“header_leadsourcecode”).setDisabled(true);

}

  • Filter Lookup

We can also filter on lookup based on another. Below we have written script to filter Existing Contact lookup based on Existing Account selected.

We have selected Fourth Coffee Account in the Existing Account as you can see in below screen shot:

img3

 

And the Existing Contact lookup will now show only Account associated Contacts in this lookup, where as previously it was showing All the contacts exist in CRM regardless of any condition.

 

 

img4

 

Below is a code snippet which will help you to filter a lookup:

function filterLookup() {

//Check if the control exist on the form

if (Xrm.Page.getControl(“header_process_parentcontactid”) != null) {

// add the event handler for PreSearch Event

Xrm.Page.getControl(“header_process_parentcontactid”).addPreSearch(addFilter);

}

}

function addFilter() {

var accountId = null;

var accountLookup;

var fetchQuery;

try {

//Check if control exist on form

if (Xrm.Page.getControl(“header_process_parentaccountid”) != null && Xrm.Page.getControl(“header_process_parentaccountid”).getAttribute().getValue() != null) {

//Get Account lookup value

accountLookup = Xrm.Page.getControl(“header_process_parentaccountid”).getAttribute().getValue();

//Get the account id

accountId = accountLookup[0].id;

}

//Build fetch

if (accountId != null || accountId != undefined) {

fetchQuery = “<filter type=’and’>” +

“<condition attribute=’statecode’ operator=’eq’ value=’0′ />” +

“<condition attribute=’parentcustomerid’ operator=’eq’ value=’” + accountId + “‘ />” +

“</filter>”;

//add custom filter

Xrm.Page.getControl(“header_process_parentcontactid”).addCustomFilter(fetchQuery);

}

} catch (e) {

Xrm.Utility.alertDialog(“addFilter Error: ” + (e.description || e.message));

}

}

  • Get/Set Value

We need to use below method to get/set the value on the BPF fields.

Xrm.Page.getControl(“header_process_descriptions”).getAttribute().getValue();

Xrm.Page.getControl(“header_process_description”).getAttribute().setValue(“Hello World”);

If you want to write a script on the header fields then you can use below line of code for this.

Xrm.Page.getControl(“header_leadsourcecode”).getAttribute().setValue(parseInt(value));

Key Points:

  • We can only perform actions like set/get value, show/hide fields, add custom filter etc. but we cannot add event handlers on the BPF fields. For this we need to add the same field on the form and then add event handler on that field.
  • As we cannot apply OOB filter lookups on the BPF fields, achieving through scripts is an advantage.

Change Tracking Feature of CRM 2015 Online Update 1

$
0
0

As we have integration of Dynamics CRM with other external systems, in that case we need to keep track of changes that were done after last synchronization of data and we integrate only those changes in external system. To achieve this previously we have to add some kind of custom logic like add one date field in CRM to track the date of last synchronization. Now, in CRM 2015 update 1 we have a built-in functionality to achieve this, it is called Change Tracking.

Change Tracking is used in Dynamics CRM to keep the data synchronized in a better way by detecting what data has changed since the data was last synchronized.

To retrieve the changes for an entity, we need to enable the Change Tracking functionality for that entity.

This feature can be enabled by using the customization user interface (UI) or programmatically by setting the ChangeTrackingEnabled property to True.

ChangeTracking2

To achieve this functionality CRM 2015 has introduced a new request called RetrieveEntityChangesRequest.

When you execute this request for the very first time, then it returns all records for the entity and that data can be used to sync into any other external system. The message also returns a DataToken that we can use in the RetrieveEntityChangesRequest, so that when we execute this request the next time then it returns data for those changes that occurred since last execution of request.

If you want to get the changed data(created/updated/deleted) of Account since last execution of request then RetrieveEntityChangesRequest message is used to retrieve the data. After executing this request it will return the BusinessEntityChangesCollection of new/updated and deleted records. The new/updated records can be retrieved from NewOrUpdatedItem and deleted item can be retrieved from RemovedOrDeletedItem.

Following is the sample code for RetrieveEntityChangesRequest:

RetrieveEntityChangesRequest changeTracking = new RetrieveEntityChangesRequest();
//set the properties
changeTracking.Columns = new ColumnSet(true);
changeTracking.DataVersion = “471550!05/15/2015 10:08:13″;
changeTracking.EntityName = “account”;

changeTracking.PageInfo = new PagingInfo() { Count = 5000, PageNumber = 1, ReturnTotalRecordCount = false };

RetrieveEntityChangesResponse res = (RetrieveEntityChangesResponse)_service.Execute(changeTracking);

//get the token
string dataToken = res.EntityChanges.DataToken;
BusinessEntityChangesCollection busEntChanColl = res.EntityChanges.Changes;

for (int bizColl = 0; busEntChanColl.Count > bizColl; bizColl++)
{
if (busEntChanColl[bizColl].Type.ToString().ToLowerInvariant() == “neworupdated”)
{
NewOrUpdatedItem createUp =(NewOrUpdatedItem) busEntChanColl[bizColl];
Entity changedEnt = createUp.NewOrUpdatedEntity;
}
else if(busEntChanColl[bizColl].Type.ToString().ToLowerInvariant() == “removeordeleted”)
{
RemovedOrDeletedItem removeOrDelItem = (RemovedOrDeletedItem)busEntChanColl[bizColl];
EntityReference delItem = removeOrDelItem.RemovedItem;
}
}

If you doesn`t provide the DataVersion parameter for request then it will always return all records.

So to retrieve only records those are Created/Updated/Delete after the last execution of request then you have to provide the DataVersion parameter, DataToken returned by previous execution of request is what we have to pass as DataVersion new value for the next request.

For example: res.EntityChanges.DataToken in the above code snippet gives us the DataToken.

If you have the windows service/ windows application for integration of CRM with another system then you can store the DataToken value in app.config. If you used it in a plug-in or a workflow then it is better to create custom entity to store value of DataToken.

Business analytics using Maps in Dynamics CRM

$
0
0

This is Part 2 of our Maplytics solution series, which allows you to integrate your Dynamics CRM with Bing Maps for all entities. In Part 1, we saw replies to some of common FAQ’s on the solution. Today let’s see some features and how adding this solution to your CRM can help you analyze your business in a much better way and help you provide Smart Customer Service. We use maps for our daily use, so why not for business.

Maplytics is used across all industries and by all roles. Ofcoz the two most common people in your organization who would use this often is the Manager and the Salesperson. Lets see what one of them has to say..

Manager - We never thought Maps could be so useful until we started using them for our business. Its now become more like an analytical tool for me. Our business is spread across cities and this helps us to keep a tab on things like service requests in an area, complaints from any area or maybe whereabouts of the daily schedule planned by my service technicians. Its all there now right in front of me in my crm. I love the heat maps in it.

Salesperson – Planning meetings is no longer a challenge. Now we can plot any entity on Bing Map from within Microsoft Dynamics CRM and make plans, print and go. The Proximity search feature in Maplytics allows us to search records within a given radius of a location. And yes, we can now find nearest meeting spots like a Starbucks or an airport quickly.

A little more about why we innovated Maplytics and its features:-
Product Page – http://inogic.com/Product/76/Integrations/Maplytics
Video – https://www.youtube.com/watch?v=UgWslSIv5MM

Why Maplytics

Mapping is like changing the game in CRM. Mapping inside of Dynamics CRM goes a step further by showing your users the way to make better business decisions. From simply having a better understanding of your data to making better, more-informed business decisions – maps have the power to transform your business. 

maplytics

Maplytics Features:

1. Plot any entity: Maplytics supports for all entities in Dynamics CRM. User can plot any entity on Bing Map from within Microsoft Dynamics CRM.
2. Save geographical search: Maplytics allows user to save geographical search results. The search results can be saved as static personal views in CRM.
3. Heat Maps: Maplytics also support Heat Maps. Heat maps helps to understand the concentration of your biggest accounts, opportunity, hot leads or any other entity.
4. Color coding of pushpins: With Maplytics user can color code pushpins based on configurable categorization in Microsoft Dynamics CRM.
5. Search records: Maplytics provides the ability to search records within a given radius of a location.
6. Print and Export search results: Maplytics allows to print or export search results to an external file.

Want to know more, why not just see a live demo or opt in for our 15 days fully functional trial. Email us on crm@inogic.com with your CRM version.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Business analytics using Maps in Dynamics CRM appeared first on Inogic Blog.

Querying More than 5000 records in Dynamics CRM

$
0
0

Introduction

There are multiple ways provided in Dynamics CRM SDK to query and read data like

  1. Using ODATA
  2. Using FetchXML
  3. Using Query object

ODATA has a limitation where it can return only 50 records at a time. You can ofcourse query more than that but it would be in batches of 50 records at a time.

Fetch XML queries on the other hand will allow you to read upto 5000 records in one go with the ability to read the next 5000. Since requesting 5000 records at a time may not really be a good idea because of the network resources that would use and potentially slow down or even time out depending on the network speeds, it is always a good idea to read data in small manageable sets of records. Fetch queries when executed return paging cookies when you implement paging and this helps you to implement a system where you would like to read a fixed count of records and provide a next/prev button to access additional records.

Query Records using Fetch

<fetch mapping=”logical” output-format=”xml-platform” version=”1.0″ page=”1″ paging-cookie=”” >

<entity name=”account” >

<attribute name=”name” />

<attribute name=”address1_city” />

<order descending=”false” attribute=”name” />

<filter type=”and” >

<condition attribute=”ownerid” operator=”eq-userid” />

<condition value=”0″ attribute=”statecode” operator=”eq” />

</filter>

<attribute name=”primarycontactid” />

<attribute name=”telephone1″ />

<link-entity visible=”false” name=”contact” link-type=”outer” to=”primarycontactid” from=”contactid” alias=”accountprimarycontactidcontactcontactid” >

<attribute name=”emailaddress1″ />

</link-entity>

<attribute name=”industrycode” />

<attribute name=”donotbulkemail” />

<attribute name=”creditonhold” />

<attribute name=”accountid” />

</entity>

</fetch>

The above code works fine as long as there are less than 5000 records in the system. When the records fetched count went above 5000+ records we started getting following error:

report

So if you notice in our above fetch xml we are providing “paging-cookie” as blank. So once the records retrieved count goes above 5000+ records we started getting the above shown error. For Fetch to bring records above 5000+ it requires paging-cookie to be set in the fetch tag

Setting the Paging Cookie

Where do we find the paging cookie?  The answer is fetch response. Whenever we make a fetch request the response which we get back from fetch has paging-cookie in it. We need to extract that paging-cookie from response which we can send to our next page fetch request. In addition to paging-cookie we also get “MoreRecords” which is Boolean which tells us if there are any more records to fetch.

When we are on first page we provide the paging-cookie as blank as the first page doesn’t need a paging-cookie. When the fetch query is executed it brings the page-cookie with it in the resultant response which looks like this:

“<cookie page=\”1\”><name lastnull=\”1\” firstnull=\”1\” /><accountid last=\”{98B36F67-3A21-E511-80FC-C4346BAD2660}\” first=\”{A6B16F67-3A21-E511-80FC-C4346BAD2660}\” /></cookie>”

To get this page-cookie from response we extract it from resultant fetch response as follows:

Var pagecookie = $(resultXml).find(“a\\:PagingCookie”).eq(0)[0].text;

You can find that since we are on first page it returns the page as “1”. Since the fetch is for “Account” entity it returns the first accountid and last accountid for that page in page-cookie. When we request for the next page we provide this page-cookie from first page to the next page fetch query request.

In the same way we can extract “MoreRecords” as follows:

Var moreRecords = $(resultXml).find(“a\\:MoreRecords”).eq(0)[0].text

This returns “true” or “false” which helps us to determine if we reached last page or still there are any records to fetch.

Updated Code

var xmlDocument = parser.parseFromString(fetchxml, “text/xml”);

var fetch = $(xmlDocument).find(‘fetch’);

fetch.attr(‘page’, page);

fetch.attr(‘count’, pageCount);

fetch.attr(‘paging-cookie’, pagingCookie);

In above code we are providing “pagingCookie” variable to which we set the page-cookie which we get from response in fetch attribute along with page and pagecount.

So now when you checkout the fetch query it be as follows :

<fetch count=”250″ mapping=”logical” output-format=”xml-platform” version=”1.0″ page=”18″ paging-cookie=”&#60;cookie page&#61;&#34;1&#34;&#62;&#60;name lastnull&#61;&#34;1&#34; firstnull&#61;&#34;1&#34; &#47;&#62;&#60;accountid last&#61;&#34;&#123;98B36F67-3A21-E511-80FC-C4346BAD2660&#125;&#34; first&#61;&#34;&#123;A6B16F67-3A21-E511-80FC-C4346BAD2660&#125;&#34; &#47;&#62;&#60;&#47;cookie&#62;” /></cookie>”>

<entity name=”account” >

<attribute name=”name” />

<attribute name=”address1_city” />

<order descending=”false” attribute=”name” />

<filter type=”and” >

<condition attribute=”ownerid” operator=”eq-userid” />

<condition value=”0″ attribute=”statecode” operator=”eq” />

</filter>

<attribute name=”primarycontactid” />

<attribute name=”telephone1″ />

<link-entity visible=”false” name=”contact” link-type=”outer” to=”primarycontactid” from=”contactid” alias=”accountprimarycontactidcontactcontactid” >

<attribute name=”emailaddress1″ />

</link-entity>

<attribute name=”industrycode” />

<attribute name=”donotbulkemail” />

<attribute name=”creditonhold” />

<attribute name=”accountid” />

</entity>

</fetch>

Note:

Make sure to encode the fetchxml request to cover for any special characters in the data. Let us explain with an example, for one of the result sets of the above fetch we found the paging-cookie received a special character – single quote (‘) in one of the records name field. This field was referenced in the paging-cookie.

Example:

“<cookie page=\”2\”><fullname last=\”Susan’s Burk (sample)\” first=\”Rene Valdes (sample)\” /><contactid last=\”{349DB5FF-DA1B-E511-80F1-C4346BACD1A8}\” first=\”{2E9DB5FF-DA1B-E511-80F1-C4346BACD1A8}\” /></cookie>”

In above example you can see that the fullname last=\”Susan’s Burk (sample)\” has (‘s). This (‘) used to break the fetchxml and hence started throwing “Page Cookie Malformed” exception when trying to execute fetchxml request.

To resolve this you need to encode the paging-cookie before it is insert in the fetch xml.

Traversing backwards

Using the paging-cookie you can traverse forward to the next set of results. But if you want to implement the previous button or you want to allow navigation to a specific page, you need to make sure you store the paging-cookie received for each of the pages.

To deal with this you can save the page-cookie for example in the array for the pages which you move forward and use this later to get the page-cookie for that particular page when moving backward in paging.

Conclusion

Using Paging-cookies effectively, you can implement paging without actually retrieving all the records at one-go. Query records only when requested and display for better performance results.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Querying More than 5000 records in Dynamics CRM appeared first on Inogic Blog.

Converting Date/Time based on user timezone in SSRS reports for Dynamics CRM Online

$
0
0

Converting Date/Time values according to a timezone is quite easy in languages like javascript, C#, etc. but achieving this in SSRS reports is a challenging task. For CRM online we can achieve this using CRM parameter in SSRS reports.

We have covered a work around to achieve this functionality in SSRS reports for CRM online.

Scenario:

We had a request from one of our clients in which the client used to run a report on the last day of every month.

The client used to pay commisions to the users as per the goals achieved by them in the month, so he runs the report on the last day of the month. Somehow the report when ran didn’t show the proper data and the reason was the timzone difference between the user and the UTC timezone.

Since the report was made to show records of the current month so when the client ran the report on May 31 it unexpectedly showed the details of June because till that time the date has changed to June 01 in UTC.

Resolution:

After so much googling also we could not find a way to tackle this situation. So we tried to know the principles used in the OOB reports of CRM to handle this situation as they always run without any issues and show the perfect data all the time.

To know what is the logic used in the OOB reports we downloaded the Account Summary report available in system and we found two things that are used to achieve this functionality:

  1. CRM parameter: CRM_UserTimeZone
  2. Assembly reference:Crm.Reporting.RdlHelper

To incorporate these changes in our report we created a parameter CRM_UserTimeZone to store the user time zone as shown below:

report

After adding the parameter in the report we need to add the assembly refrence, to add the refrence go to Report Properties and click on the References tab. Now click on the Add button, since the assembly we need to add in the report is only available on the reporting server so we cannot browse and add a URL to it.

To overcome this we need to just paste the following URL in the browse textbox as shown below:

URL: Microsoft.Crm.Reporting.RdlHelper, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

The above URL is found in the refrences of the Account Summary report.

report1

After adding the assembly reference we need to initialize a variable which will contain the user current datetime. To do this we use the following code:

=CDate(Microsoft.Crm.Reporting.RdlHelper.DateTimeUtility.ConvertUtcToLocalTime(DateTime.UtcNow, Parameters!CRM_UserTimeZoneName.Value))

In the above code, we have converted the UTC time to user local time using theCRM_UserTimeZoneName parameter so it provides us the flexibility to run the report on the last day of each month.

Note: If we run this report in the dev machine then it gives an error of missing references as shown below:

report2

But when this report is rendered in the online environment then it loads the referenced assembly from the CRM online environment and shows the proper data.

report3

Summary

It is clear from the above example that we can use the CRM parameters to make our reports user-friendly and to show user-specific data.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Converting Date/Time based on user timezone in SSRS reports for Dynamics CRM Online appeared first on Inogic Blog.

Accessing related entities fields in Calculated Fields formulas in Microsoft Dynamics CRM 2015

$
0
0

Introduction:

In our recent blog post about calculated fields we have covered about calculated fields support extended for Date/Time data types in Dynamics CRM 2015 Online Update 1. You can read this blog here. In this blog we will focus on accessing related entities fields in calculated fields formulas.

In Calculated fields, you can define the formula at the time of adding the field itself. This ensures it is executed at all times, server-side. But since it is updated synchronously you can see the updates immediately upon save.

Calculated fields can only use N:1 look up fields. We cannot use N:N or 1:N relationship for Calculated fields.

Walk-through:

Let’s see how we can use related entities look up fields in calculated fields formula.

Consider an example where we need to calculate the Budget for Opportunity Entity using the formula:

Budget(Opportunity)=Budget(Account) – ( Budget(Account)*0.002)

To accomplish this,

1. We will first create Budget field as calculated field on Opportunity Entity. As we createBudget field as Calculated Field it becomes read only on the form.

calculated field         

2. To define the calculation for Budget field click on Edit button that appears only when Field type is Calculated or Rollup.

calculated field1

This opens a UI similar to Business Rules where we can define calculation.

calculated field2

3. When setting the action and formula, you get intellisense to support the common functions. Using the intellisense, we can use the related entity by using the lookup fields name of that entity.calculated field3

4. The lookup fields name allows access to all fields of the look up entity.calculated field4

5. For above requirement we have defined the conditions and actions as below:calculated field5

Now, when you create a new record, upon Save you will find the Budget automatically set.

Conclusion:

With this extended support we can perform calculations that require related entities fields using calculated fields.

Stuck with migration to Dynamics CRM? Experts at Inogic are always happy to help you, get in touch with us on crm@inogic.com.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Accessing related entities fields in Calculated Fields formulas in Microsoft Dynamics CRM 2015 appeared first on Inogic Blog.

Calculated fields support extended for Date/Time data types in Dynamics CRM 2015 Online Update1

$
0
0

Introduction:

Calculated fields was first introduced in Dynamics CRM 2015 and it further improved upon the ability to provide codeless solutions to power users to configure. You can learn more about its features from our earlier blog here.

It provided support for most CRM data types however the calculations and formulae supported for Date/Time fields were still limited.

With the latest Online update, they have enhanced the operations supported on Date/Time fields.

  1. DIFFINDAYS(start date or time, End date or time)
  2. DIFFINHOURS(start date or time, End date or time)
  3. DIFFINMINUTES(start date or time, End date or time)
  4. DIFFINWEEKS(start date or time, End date or time)
  5. DIFFINYEARS(start date or time, End date or time)
  6. DIFFINMONTHS(start date or time, End date or time)

The Rollup field has also been enhanced to support AVG as an aggregate calculation for Date/Time fields.

How does this help?

A very real scenario where this code be used is to calculate the Avg. time it takes for resolving a complaint.

The Actual Units fields in the Case entity calculates the total time spent on the case by adding up the times on the individual activities associated with the case. But what if you wanted to know just how long a case had been open – case createdon – case modifiedon.

Next it would be good to have the Avg. case resolution time per customer, to monitor if there are particular customers for which is usually takes too long to close a case. What we are looking out for here is Avg. Case closure time.

Walkthrough

Let us see how to go about getting this set up in no time.

  1. Add the Calculated field.

calculated fields

Since we have created a Duration field, we would calculate the difference between CreatedOn and ModifiedOn in minutes. Note. Duration field always expects the values to be provided in minutes.

calculated fields1

  1. Create the Rollup field.

              We will add the rollup field on Account to get the Avg. Resolution time.

calculated fields2

                       Rollup the time for only resolved cases.

calculated fields3

  1. Place both the fields on the Case and Account forms respectively.
  2. Now when you resolve the case, you will find that the case resolution time is auto calculated.

calculated fields4

  1. We quickly closed a few cases for this account so that the avg. could be calculated

calculated fields5

  6.   Now lets check how it looks on the Account form

calculated fields6

Conclusion:

Though this takes a step further in supporting date/time data type in Calculated and Rollup fields, Rollup fields still do not support Date conditional operators like Last X months/years etc. So if I wanted to get the avg. case closure time in the last 6 months, I still cannot do that. Hoping to see this included in future version to support a full code-less power-user configuration solution.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Calculated fields support extended for Date/Time data types in Dynamics CRM 2015 Online Update1 appeared first on Inogic Blog.

Keywords : Calculated field, Dynamics CRM 2015, Date/Time data types, Dynamics CRM 2015 Online update 1, 


Hierarchy Support in Dynamics CRM 2015 SDK

$
0
0

Introduction

Hierarchies were introduced in Dynamics CRM 2015.  Hierarchy provided a way for visualizing relation between records and identify where the records reside in parent child relationship.

As in example below shows where “Test Account02” situated in hierarchy tree.

Hierarchy_Support

SDK Support

To support the ability to retrieve records based on Hierarchy, the SDK was enhanced and new operators added that would allow you to specify the records to be selected in the hierarchy.

There are new conditional operators has been added in CRM SDK to utilize record hierarchy feature and retrieve records in hierarchy.

Listed below are the conditional operator can be used to retrieve records in hierarchy. We retrieved the records on account form load for account “Test Account02” and displayed in alert dialog to check the result. Below are the condition operator and its description.

1. above

Operator Scope: Can be used as conditional operator for the entity record.

Description: This retrieves records which are above the records in tree. In case of “Test Account02” it is “Test Account01” as below.

Hierarchy_Support1

Note : When records is retrieved with same operator for  account “Test Account05”.This will retrieve account “Test Acccount01” and “TestAccount02”.Accounts ”Test Account04” and  “Test Account03” are not part of the result.

2. eq-or-above

Operator Scope: Can be used as conditional operator for the entity record.

Description: This includes records above the specified record including record itself. In case of “Test Account 02” the result is as below.

Hierarchy_Support2

 3. under

Operator Scope: Can be used as conditional operator for the entity record.

Description: This operator used to retrieve records below the specified record in hierarchical tree. For “Test Account02” the result is as below.

Hierarchy_Support3

For the record “Test Account01” the result records are “Test Account02”,”Test Account03” ,”Test Account04” and ”Test Account05”.

 4. eq-or-under

Operator Scope: Can be used as conditional operator for the entity record.

Description: This operator is used to retrieve records below specified record in hieratical tree including the record. For “Test Account02” the result is as below.

Hierarchy_Support4

 5. not-under

Operator Scope: Can be used as conditional operator for the entity record.

Description: This operator used to retrieve records which are not below specified record. Result includes the current record too. This will be usable in combination with other operators. For “Test Account02” the result is as below. This includes all records except “Test Account05”.

Hierarchy_Support5

6. eq-owneduseroruserhierarchy

Operator Scope: Can be used as conditional operator for the owner field.

Description: This Operator used to retrieve records owned by user and also the records which are not owned by login user but part of hierarchy. We have created new account “test Account08” which is owned by another user. But its parent account is “Test Account03” as below.

Hierarchy_Support6

For “Test Account08” the result is as below.

Hierarchy_Support7

 7. eq-useroruserhierarchyandteams

Operator Scope: Can be used as conditional operator for the owner field.

Description: This Operator used to retrieve records owned by user and records owned by user in hierarchy.

Below is the screen shot shows Position “P1” and “P2” are related.

Hierarchy_Support8

Position “P1” contains first user and position “P2” contains user “John” as below.

Hierarchy_Support9

Hierarchy_Support10

Record “Test Account08” and “Test Account09” are owned By “Jon”. Since both users are related in hierarchy result for “Test Account03” will be as follows.

Hierarchy_Support11

“Test Account08” and “Test Account09” account records are included in the result.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Hierarchy Support in Dynamics CRM 2015 SDK appeared first on Inogic Blog.

Dynamics CRM and Bing Maps integration using Maplytics – Add More Happy Customers

$
0
0

This is Part 1 of our series on some of the most common FAQ’s on our Maplytics solution which allows you to integrate your Dynamics CRM with Bing Maps for all entities.

maplytics

Why Maplytics?

First thing, Dynamics CRM does come with a Bing Map integration out of the box. Our solution takes this a step ahead, it allows you to integrate all entities including custom entities so you can explore more on customer statistics, know them better, serve them better and have more happy customers and obviously Grow your Business.

Do proximity search, color code your pushpins the way you want, have heat maps, export your results and much more.

Product Page – http://inogic.com/Product/76/Integrations/Maplytics
Video – https://www.youtube.com/watch?v=UgWslSIv5MM

Before we proceed, will it affect my existing customizations?
No, it is supplied as a managed solution that is easy to install and un-install without affecting your existing customization.

What versions does it support?
Maplytics supports all CRM deployment models namely on-premise, on-line, office 365 and partner-hosted. It supports Dynamics CRM 2011 and above.

Pricing?
Maplytics is available at 10USD per user per month. Special offers and volume discounting is also available. Don’t worry price is …..% (You can’t value how beneficial it would be for your business) of your business profit.

Can I grab a Trial?
Ofcoz, opt in for our 15 days fully functional trial. Email us on crm@inogic.com with your CRM version and deployment (on-prem or online) model.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Dynamics CRM and Bing Maps integration using Maplytics – Add More Happy Customers appeared first on Inogic Blog.

Keywords : Dynamics CRM, Bing maps, dynamics CRM and bing maps integration, Maplytics, Mapping tool for Dynamics CRM

Immersive Excel Experience with Dynamics CRM 2015 Online Update 1

$
0
0

Introduction:

Export to Excel has been a feature that has been in Dynamics CRM since its initial release. Though it did the job, there were some annoying pop-up’s and probably a few clicks that could well be avoided. With the Online Update 1, the Export to Excel experience is set to change for the better.

Excel File Format:

In the earlier versions of Dynamics CRM, when you exported the data to Excel and tried to open the Excel file, you were prompted with this dialog

e1

We have been used to clicking on Yes and proceed further with opening the excel file.

With the latest update in place, you will not receive these innocuous messages.

Editing Excel:

Export to Excel has always had the feature to export the data for reimport.

e2

 

When this option was selected, the excel file exported would add the hidden GUID column to the excel sheet and you could then edit and import this sheet back into CRM. However the process was a 3 step process

  1. Export for re-import.
  2. Edit in Excel.
  3. Import the new excel file saved in CSV format using Import Tool.

Enhanced process of Editing

To avoid the 3 step process, you now can simply edit the records in-place. In a way you now have an Editable Grid in CRM. You can convert any of the CRM Views into an Editable Grid for basic field data manipulation and batch editing of records.

You can access this feature “Open in Excel Online” under the Export to Excel button available on all grids.

e3

Once you click on it you are directed to Excel Online page as you can see below:

e4

You can use any Excel Formulas you want and even edit the records if you wish to use.

Suppose we change the Account Name to “Name Updated”.

e5

We can even add any new records by adding data in the next row and saving the excel back to CRM.

e6

The record would be created in CRM when we click “Save the changes back to CRM”.

e7

You can see the record is created in CRM as below:

As soon as we click the “SAVE CHANGES TO CRM” following dialog shows up

e8

We can check the status of importing process at “Settings/ Data Management/Imports”.

e9

We can monitor the Import Job status from the Import Job. It shows the Creates and Updates performed in CRM due to the import. In our case it shows “Create” and “Update” as follows:

e10

Once the import job successfully completes, you can see the updates reflected in CRM. The Failures if any can be monitored in the job as well.

Security:

In order to use this functionality the user must have “Export to Excel” privilege.

e11

It appears you do not need to have an active Excel Online subscription for this to work. This was tested on an Org that did not have any active Office subscription.

Conclusion:

Easy to use, bulk editing tool with the power of Excel is now in your hands with this feature.

Hope it helps!

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Immersive Excel Experience with Dynamics CRM 2015 Online Update 1 appeared first on Inogic Blog.

Keywords : Dynamics CRM, CRM 2015, Dynamics CRM 2015 online Update 1

How to Open Quick Create form in Dynamics CRM 2015 Online Update 1

$
0
0

You might be aware of how to open CRM entity form using javascript function that was introduced in Dynamics CRM 2013 i.e. Xrm.Utility.openEntityForm()

If you are not then you can refer our blog about this feature here. We use openEntityForm function to open blank entity form or entity form with pre populated values.

In CRM 2013 there was new feature introduced called Quick Create Form, using quick create form user can quickly create new record by staying on the same page.

The quick create form opens as below,

form

And there was no function or an option to open such quick creates form programmatically.

Sometimes we may need to open Quick create form programmatically. Microsoft has introduced new function in Dynamics CRM 2015 Online Update 1 to open quick create form same as open entity form.

This blog will illustrate how to open Quick create form.

Now there is one function available under Xrm.Utitlity called ‘openQuickCreate’ that open entity open form as shown in above screen shot.

Syntax,

Xrm.Utility.openQuickCreate(entityLogicalName,createFromEntity,parameters).then(successCallback,errorCallback);

Here,

entityLogicalName: Accept string value. Pass logical name of entity for which we need to open quick create form,

createFromEntity: Accept a lookup object, Pass lookup object that will provide default values based on mapped attributes values.

parameters: Accept a object, pass extra querystring parameters. We can pass field values as a parameter to set field values on the quick create form.

successCallback: This is a function that will call when record is created. It returns a lookup object of created record.

errorCallback: This is a function that will be called when error occurred. It returns errorCode andmessage.

From all above parameter only entityLogicalName is required and others are optional.

Below is an example where we will open Quick Create form to create a new child account from account entity form with some pre populated values.

//lookup object of current account record

var parrentAccount = {

 entityType: “account”,

 id: Xrm.Page.data.entity.getId()

};

var parameters = { name: “Child account of ” + Xrm.Page.getAttribute(“name”).getValue(), address1_postalcode: Xrm.Page.getAttribute(“address1_postalcode”).getValue() };

Xrm.Utility.openQuickCreate(“account”, parrentAccount,parameters ).then(function (lookup) { successCallback(lookup); }, function (error) { errorCallback(error); });

function successCallback(lookup)

{

        window.console.log(“lookup: ” + lookup.savedEntityReference.id);

}

function errorCallback(e){

        window.console.log(“Error: ” + e.errorCode +” “+e.message);

}

Above code opens a quick create form with auto populating name and postal code from parent account.

form1

The successCallback() calls when you save the record.

Hope it helps!

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post How to Open Quick Create form in Dynamics CRM 2015 Online Update 1 appeared first on Inogic Blog.

One Note Integration with Dynamics CRM 2015 Online Update 1

$
0
0

Introduction:

In today’s world there would be very few who perhaps still use notepad or like application for taking notes. Majority use application like OneNote or EverNote to manage their notes. These application allow recording of rich data like pictures, videos etc within the application for later consumption. Recording notes traditionally in CRM has been through the Notes tab, that allows you to record multiple notes, but it has to be text. It supports file attachments though.

In the latest CRM Online release, Dynamics CRM would now provide a seamless integration to OneNote, this means you can now from within CRM directly record notes into OneNote and easily access them from within CRM.

Enabling this feature

This feature is built upon the Sharepoint Integration framework and requires that you have Sharepoint Integration enabled for CRM. So the first step would be to enable Sharepoint Integration

Navigate to Settings >> Document Management.

In this example we will “Enable Server- Based SharePoint Integration” and enter the valid SharePoint Url to integrate CRM with SharePoint account. 

img1

Once we integrate SharePoint with CRM, the OneNote Integration option is listed in document management as shown below in the screenshot.

img2

Then enable the OneNote and it will open “OneNote Integration Settings” in which we will select the entities for which we want to turn on OneNote integration. It will only list those entities for which Sharepoint Integration had been enabled.

img3

Once the OneNote integration has been enabled, you now start seeing a new option at the entity level in the customization screen

img4

For any new entity that you want to enable OneNote integration, you need to make sure, you check the Document Management and OneNote Integration options on the entity level.

Next run the Document Management Wizard to have the libraries created in Sharepoint for these entities.

img5

Once you have the integration enabled, you would find a new option ONENOTE showing in the Social Pane on the form.

img6

Since Sharepoint Integration needs to be enabled for OneNote integration, if you click on the onenote tab you would see the following error if no sharepoint library was already created for this record.

img7

Once the library is created, clicking on the ONENOTE tab will automatically create a OneNote notebook for the record with the same name as the record name and an untitled page will show up in the notes as shown below

img8

When you navigate to the Documents pane in the CRM, you will see the following files created in Sharepoint

img9

Note: Do not delete the .onetoc2 file found in the Sharepoint library. That file is necessary for the integration to work.

You can click on the Untitledonenote file in the OneNote pane, to directly open the OneNote file in OneNote Online.

img10

Adding a new Section in the notebook will add a new listing in the ONENOTE tab of the form.

img11

img12

You can create multiple sections but they will all be stored in the same notebook. Multiple notebooks cannot be created for a single record in CRM.

Changing the OneNote page name and the file name that appears in the OneNote pane.

Untitled is not a very descriptive or friendly name to have for a file. But unfortunately, the default file/page that is created for one-note integration is called untitled. What we found that renaming the Untitled Notebook after opening it in OneNote Online did not change the file name.

Also notice in the above screenshot, the date/time in the untitled page is also not the current date/time.

To fix this

  1. Go ahead and delete the default Untitled Page and the Untitled Section that shows up
  2. Create a new Section clicking the “+” button on the section

Give the name you want to see in CRM. In our case we have considered “CRM Section using OneNote App” and saved. The new section would be created in ONENote as follows:

img13

This now also reflects the current date/time.

  1. When you come out of OneNote and navigate back to the OneNote tab in CRM you will see the updated name

img14

  1. Another way to rename the section name is to do it through the desktop version of OneNote.

Security Privileges that control OneNote Integration

No new settings or privileges have been introduced related to ONE NOTE. However since it is very closely tied to Sharepoint Integration, privileges that control Sharepoint Integration essentially control the OneNote integration as well.

Suppose a user has a role with No create , read and Write privilege for Document Location as shown below :

img15

If this user tries to create a ONENOTE clicking the Tab one note is not created or loaded and following error is displayed

img16

And finally, the user needs to have access to the Sharepoint Document Library in Sharepoint to be able to access the onenote file.

Conclusion

You can now access OneNote file from right within Dynamics CRM, without the need to manually upload or download the file to make updates.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post One Note Integration with Dynamics CRM 2015 Online Update 1 appeared first on Inogic Blog.

Dynamics CRM 2015 Online Update 1 – API support for Transaction

$
0
0

Introduction:

As a developer, you always want to perform any database operation in a Transaction so that you have the choice of rollback in case an operation fails. There are many examples where you want either all of your API instructions to succeed or all of them to rollback. If there is only a partial successful execution, it could lead the database in an unstable state. This is especially true of scenarios where you would like to create one record with multiple other related records. You want the master record created only if all other related records could be successfully created as well. If any related operation fails, do not create the master record as well.

Unfortunately, until this update, Dynamics CRM did not support transaction for actions performed through the API by the developers.

ExecuteTransactionRequest:

This is a new request that is introduced with the Dynamics CRM Online Update 1 (7.1.x).  With this request you need to provide a collection of Organization request like Create, Update, Delete, SetState, Assign, any organization request and have CRM execute them in a transaction. This means any of the request in the collection fails, all the other requests would also rollback. The response of this request would also be a collection of responses corresponding to every request that was included in the request collection.

ExecuteTransactionRequest execTrans = new ExecuteTransactionRequest()

{

ReturnResponses = true,

Requests = new OrganizationRequestCollection()

};

Below is an example of how could you add different organization requests in the request collection. Note, we are adding different messages for the sake of clarity about this message.

///// Create Account Request//////

Entity account = new Entity(“account”);

account["name"] = “Transaction request 1″;

CreateRequest createAcc = new CreateRequest();

createAcc.Target = account;

//add create request in a request collection

execTrans.Requests.Add(createAcc);

////// Update request ///////

Entity contact1 = new Entity(“contact”);

contact1["firstname"] = “Samantha”;

contact1["lastname"] = “Ray”;

contact1[“emailaddress1”] = “sammy@example.com”;

//set gender value

contact1[“gendercode”] = new OptionSetValue(3);

//Update request to update a contact

UpdateRequest upReq = new UpdateRequest();

upReq.Target = contact1;

upReq.Target.Id = new Guid(“58C7D2CB-7A0E-E511-80DC-FC15B4289E14″);

//add update request in a collection

execTrans.Requests.Add(upReq);

///// Status Change Request //////

SetStateRequest state = new SetStateRequest();

//set the reference of target entity

state.EntityMoniker = new EntityReference(“contact”, new Guid(“A925C42D-CFE4-E411-80E8-C4346BAD5414″));

//set the state of the record to inactive

state.State = new OptionSetValue(1);

state.Status = new OptionSetValue(2);

//add set state request in collection

execTrans.Requests.Add(state);

///// Delete request //////

DeleteRequest delete = new DeleteRequest();

//provide target entity reference which needs to be deleted

delete.Target = new EntityReference(“account”, new Guid(“4125C42D-CFE4-E411-80E8-C4346BAD5414″));

//add delete request in collection

execTrans.Requests.Add(delete);

Finally execute the ExcecuteTransaction Request

//Execute the request

ExecuteTransactionResponse response = (ExecuteTransactionResponse)_service.Execute(execTrans);

The response of this can be read as shown below

response.Responses would contain the collection of the responses returned for each of the request submitted to the request above.

You can read the response for each of the individual request by matching the index in the request collection with that in the response collection.

img

For the create request, the response would provide the id in the response.

OrganizationResponse resp = response.Responses[0]

Since this was a createRequest, the response would be the CreateResponse that is returned. You can find the Guid of the newly created record

id = (Guid)orgResponse.Results["id"];

If an error occurs in executing any of the message in the collection, it would throw a fault exception of the type ExecuteTransactionFault which will return the index of a request collection of the request message that caused the fault.

Here is how it looks in the debugger

img2

You can read it using the following code.

catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)

{

ExecuteTransactionFault fault = (ExecuteTransactionFault)ex.Detail;

int faultedIndex = fault.FaultedRequestIndex;

}

Conclusion:

Do not confuse this with ExecuteMultiple that was introduced in one of the earlier updates to Dynamics CRM. Some points to remember

  • ExecuteMultiple allowed you to process multiple messages in a single batch to reduce the roundtrips required to process multiple messages.
  • ExecuteTransaction goes a step further to ensure that all of the messages submitted to it are executed in Transaction mode. Rollback if any message fails.
  • You can include an ExecuteMultiple request within an ExecuteTransaction request.
  • The max messages that can be executed in a batch is 1000


There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Dynamics CRM 2015 Online Update 1 – API support for Transaction appeared first on Inogic Blog.

Keywords : Dynamics CRM, Microsoft Dynamics CRM, Dynamics CRM 2015, Dynamics CRM 2015 Update 1

Retrieve and Instantiate Global Email Template

$
0
0

Have you ever Retrieved or Instantiated an email template? If the answer to this question is YES, then you might be knowing the required parameters we need to have in place in order to do so.

For those of who aren`t aware of it then this blog would help you understand the tidbits involved.

We had a request in which we were supposed to use a Global Email Template for sending emails.

Well we had done the same for entity specific email template, but this was something we had never done until the request.

Let`s get started with the explanation of how we achieved it.

First, we`ll retrieve a Global Email template.

Retrieve:

Here we`ll retrieve the Global Email Template, on the basis of the Template Name. We just need the GUID for this demo, so we would just be retrieving the GUID of the template. The retrieved GUID would then be used to Instantiate the template.

Code Snippet

public void RetrieveTemplate()

        {

            string functionName = "RetrieveTemplate";

            Guid templateId = Guid.Empty;

            try

            {

                string emailTemplate = "Welcome Email";

                FilterExpression filter = new FilterExpression();

                ConditionExpression conditionTitle = new ConditionExpression();

                ConditionExpression conditionType = new ConditionExpression();

                QueryExpression query = new QueryExpression();

                //title

                conditionTitle.AttributeName = "title";

                conditionTitle.Operator = ConditionOperator.Equal;

                conditionTitle.Values.Add(emailTemplate);

                //entity type               

                conditionType.AttributeName = "templatetypecode";

                conditionType.Operator = ConditionOperator.Equal;

                conditionType.Values.Add("systemuser");

                //add conditions

                filter.FilterOperator = LogicalOperator.And;

                filter.Conditions.Add(conditionTitle);

                filter.Conditions.Add(conditionType);

                query.Criteria = filter;

                query.ColumnSet = new ColumnSet();

                query.EntityName = "template";

                query.ColumnSet.Columns.Add("templateid");

                EntityCollection templateCollection = _service.RetrieveMultiple(query);

                if (templateCollection.Entities.Count > 0)

                {

                    templateId = templateCollection[0].Id;

                    InstantiateTemplate(templateId);

                }

             }

            catch (FaultException<OrganizationServiceFault> ex)

            {

                throw new FaultException(functionName + ":" + ex.Message);

            }

            catch (Exception ex)

            {

                throw new Exception(functionName + ":" + ex.Message);

            }

        }

 Explanation

  • Entire code is similar to what it should have been for retrieving Entity Specific Email template; the difference here is the part where we specify "templatetypecode”.
  • If the template is an entity specific template, then we would have used the respective entity`s logical name, but in this case we are retrieving a Global Email Template, then what could be "templatetypecode"? Here is a trick; we need to use "systemuser" as the "templatetypecode".  And this simple it is to retrieve Global Email Template.
  • Using the above code, we`ll get the GUID of the global template and that GUID will then be used in instantiating the Global Email Template.

Instantiate:

Here on the basis of the retrieved GUID, we`ll instantiate the Global Email Template, and that would be the last step of this procedure.

Code Snippet

private void InstantiateTemplate(Guid templateId)

        {

            string functionName = "InstantiateTemplate";

            EntityCollection templateCollection = new EntityCollection();

            Entity template = new Entity();

            try

            {

                InstantiateTemplateRequest request = new InstantiateTemplateRequest();

                request.RequestName = "InstantiateTemplate";

                //Set Email template Id

                request["TemplateId"] = templateId;

                //Set Regarding

                request["ObjectId"] = userId;

                //Set regarding type

                request["ObjectType"] = "systemuser";

                //execute message

                InstantiateTemplateResponse response = (InstantiateTemplateResponse)_service.Execute(request);

                //Store response in collection

                templateCollection = (EntityCollection)response["EntityCollection"];

                if (templateCollection.Entities.Count > 0)

                {

                    template = templateCollection[0];

                }

             }

            catch (FaultException<OrganizationServiceFault> ex)

            {

                throw new FaultException(functionName + ":" + ex.Message);

            }

            catch (Exception ex)

            {

                throw new Exception(functionName + ":" + ex.Message);

            }

        }

Explanation

  • In the above snippet there are 3 key things to look at.
    • Template Id: It is the GUID of the template that we retrieved in starting.
    • Object Id: It is the GUID of the user from the organization. If this would have been an Entity Specific template then we would have used the GUID of any of the record from that entity.
    • Object Type: It is the systemuser in this case, since we are instantiating a Global Email Template. If it would have been an Entity Specific template then we would have used that respective entity`s logical name.
  • The noticing part was the above 3 points, rest is just executing the InstantiateTemplateRequest  and getting the response in InstantiateTemplateResponse which is further used to get the Entity from it.

Hope this helps!

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Retrieve and Instantiate Global Email Template appeared first on Inogic Blog.


Handling Date/Time fields in Microsoft Dynamics CRM 2015 Online Update 1

$
0
0

Introduction

Managing Date/Time fields in Dynamics CRM has not been easy especially when time zone come into picture and yet it is very critical to the application. Dynamics CRM being a global application was designed to support multiple timezones and the architecture design had a very noble thought behind it –

“No matter which timezone a user logs in and looks at a date/time value, the date/time should always be reflected in their own timezone”

To go ahead and support scenarios where on Date was required and not the time, they even created a format type to specify “Date-only” field.

To support this design architecture, the date time fields in the database are always stored in UTC format. The idea being the date/time could be then converted and shown in the time zone of the logged-in or the requesting user. You specify the timezone for each user in the User Options accessible through Options

Issues with storing in UTC

We sometimes only want CRM to store date as is, not really do the time conversion, no matter which time zone it is seen from, it should still display this static date as is. The date only field did not really achieve this. The date only is also stored as date with the time components as 12 am. Since it is UTC when viewed from another timezone, it would either go one day forward or a day back depending on the part of the world you are in.

Since it is stored in UTC any programmatic access to a date field would return a UTC value, which was not was really required and it required developers to add in date/time conversion code to use the date/time value retrieved from CRM.

New Enhancements

The product team has received well all the feedback sent around the issues with Date/time field type and with the Update 1 Online release, have brought about the following platform enhancements with the objective to resolve all issues around date/time fields.

They have now introduced a new setting called “Behavior” for date/time fields in Dynamic CRM 2015 Update 1, we are able to set DateTime field with different time behaviors.

Following are the behaviors:

  • User Local
  • Date Only
  • Time-Zone Independent

User Local:

When the DateTime behavior is set as User Local and format is Date and Time then the time displayed will be as per the user time zone. For example please find the screen shots below.

Here for “Interview date” field we have set the date and time behavior as “User Local”. So when this field will be set it will be seen as per the user time zone settings as follows –

 

In the above two screen shots you can find that the Interview Date field displays different time for both users as they both are from different time zones. This emulates the behaviour of all date/time fields in Dynamics CRM prior to these new enhancements. All existing date/time fields in CRM are set as User Local by default. You will need to go and manually edit the behaviour of the field if you would like it to behave as any of the following two behaviour types.

Programmatically when you retrieve this value from CRM say for example as an input parameter of a workflow, the DateTime.Kind attribute is set to UTC.

Date Only:

For date only field since only date is displayed it has no effect of the user time zone. This is a true date only field. There is no time conversion done to show this value on CRM form. It is stored just as is entered and returned when requested.

Programmatically when you retrieve this value from CRM say for example as an input parameter of a workflow, the DateTime.Kind attribute is set to none.

Time-Zone Independent:

This DateTime field will be set irrespective of the time zone of user. So in below screen shot you can find that the values for “Relieving Date” field which is of Time-Zone independent behavior shows same date time for both users although they lie in different time zones.

Programmatically when you retrieve this value from CRM say for example as an input parameter of a workflow, the DateTime.Kind attribute is set to none.

Conclusion:

With these enhancements it would be a little easier to manage the dates and avoid unnecessary conversions to get it to work.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Handling Date/Time fields in Microsoft Dynamics CRM 2015 Online Update 1 appeared first on Inogic Blog.

Keywords: Microsoft Dynamics CRM, CRM 2015, Date/Time Field, Dynamics CRM Update 1

Custom Actions in Dynamics CRM 2015 Online Update 1

$
0
0

Recap:

Back in 2013, when Microsoft introduced the concept of “Custom Actions”, we had explained this feature in this blog. With the latest update released for CRM Online versioned 7.1, this feature has further been extended.

As a quick recap, Actions in processes are a way to create custom messages in CRM for an entity, for example escalate or approve. OOB for most entities you have Create, Update, Delete, Assign, SetState messages and you have the option of writing custom business logic in the form of Plugins or Workflows on these.

You could invoke these custom action messages through Script or through C# code.

Example:

Say to implement a business process in one of the implementation, there was a need to create a message called “Escalate” for incident. Prior to the introduction of “Actions”, these were handled by adding a custom attribute and writing plugin/workflow code that tracked the change in the attribute value to execute custom logic.

For a true XRM implementation, a need was felt to be able define custom actions instead of use workarounds like the one explained above.

Here is a custom action “Escalation” that has been created.

The actual operations that need to be performed when this action is invoked is defined through the options available similar as in workflow designer.

Until now, we needed to add a custom ribbon button and invoke this action through a script. i.e this could only be invoked through a manual process. Or if it required to be automated, then you need to write a custom workflow assembly that would programmatically invoke the action.

Workflows

With this version, now instead of creating a custom workflow assembly to invoke the action, we now have a new step available “Perform Action“.

Using the Set Properties, you can now set the input parameters that was defined for the Custom Action.

Dialogs

Similar to the workflows explained above, we now also have the “Perform Action” step available in Dialogs, so Custom Actions can now be invoked through Dialogs too.


Note: An action that is designed to accept EntityCollection will not show up in the “Perform Action” since these parameter values cannot be provided through the workflow designer.

Conclusion:

It is now possible to automate the execution of the custom actions through workflow.

Hope this Helps!

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Custom Actions in Dynamics CRM 2015 Online Update 1 appeared first on Inogic Blog.

Keywords : Microsoft Dynamics CRM, CRM Online, Custom action, CRM 2015

Tips for working with Business Rules in Dynamics CRM 2015 Online

$
0
0

Introduction

Microsoft Dynamics CRM introduced Business Rules in CRM 2013 which provides custom business logic. You can read more about how to use Business Rules from one of our earlier blogs found here

In this blog we are going to show new abilities added in Business Rules for Dynamics CRM Update 1 as well as tips while working with Business Rules in CRM.

In Microsoft Dynamics CRM Online Update 1 a new ability is added in Business Rules to clear the field value. This functionality was not present in previous versions.

Example

Let us see how we can use Clear field option of Business rules, step by step using a simple example:

Consider an example where we want to use Business rule such that if the Credit Holdfield in Accounts Entity is set to No then Clear value of Credit Limit field.

To accomplish this,

We will first create a new Business rule on Accounts entity and name it as “Clear Credit Limit”.

Then we will add the if condition as below:

business_rule

For Action we will select “set field value” option

business_rule1

In the type section we get Clear Option which clears the value of specified field when “if” condition is true.

business_rule2

Note: The Clear value option is not available for Required fields.

So the final Business Rule looks as below:

Now on Activating above business rule if the Credit hold field is set to No you will see that the Credit Limit field’s value is automatically cleared.

business_rule3

Setting up a formula for a numeric field.

Another thing that we have observed while working with Business Rules is that when entering a formula and setting a value in the formula, the precision allowed in the value depends on the field being selected as one of the parties to the formula rather than the precision of the field in which the result of the formula would be set.

Suppose, We want to set Budget field using following Formula:

Budget = Annual Revenue * 0.0067

So we have created a Custom field “Budget” of type currency with precision 4.

business_rule4

The Annual Revenue field is having precision 2.business_rule5

 

While writing formulas in Business rules, if we try to multiply “Annual revenue” field with a value of higher precision than the Annual Revenue field such as 0.0067.business_rule6

Then in business rules when we click on ok it rounds up the value to the precision of Annual Revenuefield which is the field being selected as one of the parties to the formula and not to the precision of the field in which the result of the formula would be set which in our example is Budget.

In our case the value 0.0067 is rounded up to 0.01 due to precision of Annual Revenue is 2 not to the precision of Budget which is 4.

business_rule7

Workaround:

The workaround for this is to edit the Annual Revenue field and change its precision to higher precision. In our example the precision of Annual Revenue field is changed to 4.

business_rule8

After publishing the changes in form, we get proper precision of the field.

business_rule9

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Tips for working with Business Rules in Dynamics CRM 2015 Online appeared first on Inogic Blog.

Business analytics using Maps in Dynamics CRM

$
0
0

This is Part 2 of our Maplytics solution series, which allows you to integrate your Dynamics CRM with Bing Maps for all entities. In Part 1, we saw replies to some of common FAQ’s on the solution. Today let’s see some features and how adding this solution to your CRM can help you analyze your business in a much better way and help you provide Smart Customer Service. We use maps for our daily use, so why not for business.

Maplytics is used across all industries and by all roles. Ofcoz the two most common people in your organization who would use this often is the Manager and the Salesperson. Lets see what one of them has to say..

Manager - We never thought Maps could be so useful until we started using them for our business. Its now become more like an analytical tool for me. Our business is spread across cities and this helps us to keep a tab on things like service requests in an area, complaints from any area or maybe whereabouts of the daily schedule planned by my service technicians. Its all there now right in front of me in my crm. I love the heat maps in it.

Salesperson – Planning meetings is no longer a challenge. Now we can plot any entity on Bing Map from within Microsoft Dynamics CRM and make plans, print and go. The Proximity search feature in Maplytics allows us to search records within a given radius of a location. And yes, we can now find nearest meeting spots like a Starbucks or an airport quickly.

A little more about why we innovated Maplytics and its features:-
Product Page – http://inogic.com/Product/76/Integrations/Maplytics
Video – https://www.youtube.com/watch?v=UgWslSIv5MM

Why Maplytics

Mapping is like changing the game in CRM. Mapping inside of Dynamics CRM goes a step further by showing your users the way to make better business decisions. From simply having a better understanding of your data to making better, more-informed business decisions – maps have the power to transform your business. 

maplytics

Maplytics Features:

1. Plot any entity: Maplytics supports for all entities in Dynamics CRM. User can plot any entity on Bing Map from within Microsoft Dynamics CRM.
2. Save geographical search: Maplytics allows user to save geographical search results. The search results can be saved as static personal views in CRM.
3. Heat Maps: Maplytics also support Heat Maps. Heat maps helps to understand the concentration of your biggest accounts, opportunity, hot leads or any other entity.
4. Color coding of pushpins: With Maplytics user can color code pushpins based on configurable categorization in Microsoft Dynamics CRM.
5. Search records: Maplytics provides the ability to search records within a given radius of a location.
6. Print and Export search results: Maplytics allows to print or export search results to an external file.

Want to know more, why not just see a live demo or opt in for our 15 days fully functional trial. Email us on crm@inogic.com with your CRM version.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Business analytics using Maps in Dynamics CRM appeared first on Inogic Blog.

Querying More than 5000 records in Dynamics CRM

$
0
0

Introduction

There are multiple ways provided in Dynamics CRM SDK to query and read data like

  1. Using ODATA
  2. Using FetchXML
  3. Using Query object

ODATA has a limitation where it can return only 50 records at a time. You can ofcourse query more than that but it would be in batches of 50 records at a time.

Fetch XML queries on the other hand will allow you to read upto 5000 records in one go with the ability to read the next 5000. Since requesting 5000 records at a time may not really be a good idea because of the network resources that would use and potentially slow down or even time out depending on the network speeds, it is always a good idea to read data in small manageable sets of records. Fetch queries when executed return paging cookies when you implement paging and this helps you to implement a system where you would like to read a fixed count of records and provide a next/prev button to access additional records.

Query Records using Fetch

<fetch mapping=”logical” output-format=”xml-platform” version=”1.0″ page=”1″ paging-cookie=”” >

<entity name=”account” >

<attribute name=”name” />

<attribute name=”address1_city” />

<order descending=”false” attribute=”name” />

<filter type=”and” >

<condition attribute=”ownerid” operator=”eq-userid” />

<condition value=”0″ attribute=”statecode” operator=”eq” />

</filter>

<attribute name=”primarycontactid” />

<attribute name=”telephone1″ />

<link-entity visible=”false” name=”contact” link-type=”outer” to=”primarycontactid” from=”contactid” alias=”accountprimarycontactidcontactcontactid” >

<attribute name=”emailaddress1″ />

</link-entity>

<attribute name=”industrycode” />

<attribute name=”donotbulkemail” />

<attribute name=”creditonhold” />

<attribute name=”accountid” />

</entity>

</fetch>

The above code works fine as long as there are less than 5000 records in the system. When the records fetched count went above 5000+ records we started getting following error:

report

So if you notice in our above fetch xml we are providing “paging-cookie” as blank. So once the records retrieved count goes above 5000+ records we started getting the above shown error. For Fetch to bring records above 5000+ it requires paging-cookie to be set in the fetch tag

Setting the Paging Cookie

Where do we find the paging cookie?  The answer is fetch response. Whenever we make a fetch request the response which we get back from fetch has paging-cookie in it. We need to extract that paging-cookie from response which we can send to our next page fetch request. In addition to paging-cookie we also get “MoreRecords” which is Boolean which tells us if there are any more records to fetch.

When we are on first page we provide the paging-cookie as blank as the first page doesn’t need a paging-cookie. When the fetch query is executed it brings the page-cookie with it in the resultant response which looks like this:

“<cookie page=\”1\”><name lastnull=\”1\” firstnull=\”1\” /><accountid last=\”{98B36F67-3A21-E511-80FC-C4346BAD2660}\” first=\”{A6B16F67-3A21-E511-80FC-C4346BAD2660}\” /></cookie>”

To get this page-cookie from response we extract it from resultant fetch response as follows:

Var pagecookie = $(resultXml).find(“a\\:PagingCookie”).eq(0)[0].text;

You can find that since we are on first page it returns the page as “1”. Since the fetch is for “Account” entity it returns the first accountid and last accountid for that page in page-cookie. When we request for the next page we provide this page-cookie from first page to the next page fetch query request.

In the same way we can extract “MoreRecords” as follows:

Var moreRecords = $(resultXml).find(“a\\:MoreRecords”).eq(0)[0].text

This returns “true” or “false” which helps us to determine if we reached last page or still there are any records to fetch.

Updated Code

var xmlDocument = parser.parseFromString(fetchxml, “text/xml”);

var fetch = $(xmlDocument).find(‘fetch’);

fetch.attr(‘page’, page);

fetch.attr(‘count’, pageCount);

fetch.attr(‘paging-cookie’, pagingCookie);

In above code we are providing “pagingCookie” variable to which we set the page-cookie which we get from response in fetch attribute along with page and pagecount.

So now when you checkout the fetch query it be as follows :

<fetch count=”250″ mapping=”logical” output-format=”xml-platform” version=”1.0″ page=”18″ paging-cookie=”&#60;cookie page&#61;&#34;1&#34;&#62;&#60;name lastnull&#61;&#34;1&#34; firstnull&#61;&#34;1&#34; &#47;&#62;&#60;accountid last&#61;&#34;&#123;98B36F67-3A21-E511-80FC-C4346BAD2660&#125;&#34; first&#61;&#34;&#123;A6B16F67-3A21-E511-80FC-C4346BAD2660&#125;&#34; &#47;&#62;&#60;&#47;cookie&#62;” /></cookie>”>

<entity name=”account” >

<attribute name=”name” />

<attribute name=”address1_city” />

<order descending=”false” attribute=”name” />

<filter type=”and” >

<condition attribute=”ownerid” operator=”eq-userid” />

<condition value=”0″ attribute=”statecode” operator=”eq” />

</filter>

<attribute name=”primarycontactid” />

<attribute name=”telephone1″ />

<link-entity visible=”false” name=”contact” link-type=”outer” to=”primarycontactid” from=”contactid” alias=”accountprimarycontactidcontactcontactid” >

<attribute name=”emailaddress1″ />

</link-entity>

<attribute name=”industrycode” />

<attribute name=”donotbulkemail” />

<attribute name=”creditonhold” />

<attribute name=”accountid” />

</entity>

</fetch>

Note:

Make sure to encode the fetchxml request to cover for any special characters in the data. Let us explain with an example, for one of the result sets of the above fetch we found the paging-cookie received a special character – single quote (‘) in one of the records name field. This field was referenced in the paging-cookie.

Example:

“<cookie page=\”2\”><fullname last=\”Susan’s Burk (sample)\” first=\”Rene Valdes (sample)\” /><contactid last=\”{349DB5FF-DA1B-E511-80F1-C4346BACD1A8}\” first=\”{2E9DB5FF-DA1B-E511-80F1-C4346BACD1A8}\” /></cookie>”

In above example you can see that the fullname last=\”Susan’s Burk (sample)\” has (‘s). This (‘) used to break the fetchxml and hence started throwing “Page Cookie Malformed” exception when trying to execute fetchxml request.

To resolve this you need to encode the paging-cookie before it is insert in the fetch xml.

Traversing backwards

Using the paging-cookie you can traverse forward to the next set of results. But if you want to implement the previous button or you want to allow navigation to a specific page, you need to make sure you store the paging-cookie received for each of the pages.

To deal with this you can save the page-cookie for example in the array for the pages which you move forward and use this later to get the page-cookie for that particular page when moving backward in paging.

Conclusion

Using Paging-cookies effectively, you can implement paging without actually retrieving all the records at one-go. Query records only when requested and display for better performance results.

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Querying More than 5000 records in Dynamics CRM appeared first on Inogic Blog.

Viewing all 3363 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>