Thursday, December 27, 2012

How to manage queues in CRM 2011


How to manage queues in CRM 2011


Microsoft CRM 2011 has a great option of queues and using queues we could assign any custom entity to queues. Not only custom entities but also built-in entities like lead activities cases etc.
In any organization if any user has to interact with multiple entities at the same time then we can use queue feature to organizing items more effectively.
For example in my last project we have to handle admission system. For this purpose we have used queues.
 
The process for application submission is as follow

1.   Any receptionist will receive the application and submit it to admission office for further process.

2. Receptionist receives a call from anywhere and his responsibility is to generate lead.
Receptionist gets interact with two entities.
1. Admission form 
2. Lead
 
If enrolled person get qualified admission department send him a letter and when student submit his fee admission department will enrolled the student.
In the above scenario multiple users has to work on a same entity.


Enabling Queues for Lead (Built-in Entities)

 


Check the Queues box. And if you want to automatically move records to the owner’s default queue when record is created check the other check box too.
Note: Once queues enabled we cannot reverse it status. 

Enabling Queues for Custom entities


As we discuss above we could unable queues for custom entities to.


Check the queues check box and save the entity now queues is enabled on employee entity.

Default Queues

Default queues are automatically generated for user’s teams and business units. All of these can also be used for managing user rights. Here is a list of default queues items
  1. Activity
  2. Appointment
  3. Campaign
  4. Activity
  5. Campaign response
  6. Case
  7. Email
  8. Fax
  9. Lead
  10. Letter
  11. Phone call
  12. Quick campaign
  13. Recurring appointment
  14. Service Activity
  15. Task
  16. User
  17. Team

Settings Views for Queues


We could set views for the queues to make our work easier.
Currently I want to see only leads that are assigned to me or I am the owner of the lead.

1. Go to Queues item and click on New.
 2. Give the Name of the view (Leads) I am working On
 2. Click on Edit Filter Criteria.
 3. Give your criteria as below
 4. Select your columns and click on Save and Close
 5. Now you can see the View (Leads) I am working On and all the leads that required some action.

 
Hope it will helps some one. :)

Monday, November 26, 2012

Calculate Mileage in CRM 2011 using Google API

Some companies are using Mileage functionality to give there employees Travel allowance. To automate this process we can use Google API to Get the distance and give allowance to there employee.
Google Map API requires two fields Origin, Destination and it gives us its complete detail i.e. Correct address, Distance etc. But for now we only need distance to give our employee Travel allowance depending upon the distance that they travels. It is really helpful in any Marketing Company or any other company that gives Travel allowance to its employees.

Prerequisites for Integration between CRM 2011 and Google Map Api

1. CRM 2011
2. Google Map API Script File (Download)

Note: This code works on Zip code. Enter the Origin, Destination and then Cost per mile.

Here is the complete code you only need to change the Bold lines (Schema Names)


 function calculateCost()  
 {  
 var distance = Xrm.Page.data.entity.attributes.get("new_distance").getValue();  
 var costpermile = Xrm.Page.data.entity.attributes.get("new_costpermile").getValue();  
 var totalCost = distance * costpermile;  
 var Name = Xrm.Page.data.entity.attributes.get("new_totalcost");   
   Name.setValue(totalCost);  
 }  

 function GetMilesFromZipcodes()  
 {  

 //Please pass your origin and destination values here.
 var origin1 = Xrm.Page.data.entity.attributes.get("new_origin").getValue();   
 var destinationA = Xrm.Page.data.entity.attributes.get("new_destination").getValue(); 
 var distance = Xrm.Page.data.entity.attributes.get("new_distance");
 var service = new google.maps.DistanceMatrixService();  
 service.getDistanceMatrix(  
  {  
   origins: [origin1],  
   destinations: [destinationA],  
   travelMode: google.maps.TravelMode.DRIVING,  
   avoidHighways: false,  
   avoidTolls: false  
  }, callback);  
 function callback(response, status) {  
 if (status == google.maps.DistanceMatrixStatus.OK) {  
   var origins = response.originAddresses;  
   var destinations = response.destinationAddresses;  
   for (var i = 0; i < origins.length; i++) {  
    var results = response.rows[i].elements;  
    for (var j = 0; j < results.length; j++) {  
     var element = results[j];  
     var distance = element.distance.value;  
     //Convert KM to Miles
     var distance1 = (distance * 0.621371)/1000;  
    
   distance.setValue(distance1);  
     var duration = element.duration.text;  
     var from = origins[i];  
     var to = destinations[j];  
    }  
   }  
  }  
 }  
 }  
 window.google = window.google || {};  
 google.maps = google.maps || {};  
 (function() {  
  function getScript(src) {  
   document.write('<' + 'script src="' + src + '"' +  
           ' type="text/javascript"><' + '/script>');  
  }  
  var modules = google.maps.modules = {};  
  google.maps.__gjsload__ = function(name, text) {  
   modules[name] = text;  
  };  
  google.maps.Load = function(apiLoad) {  
   delete google.maps.Load;  
   apiLoad([0.009999999776482582,[[["https://mts0.googleapis.com/vt?lyrs=m@199000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.googleapis.com/vt?lyrs=m@199000000\u0026src=api\u0026hl=en-US\u0026"],null,null,null,null,"m@199000000"],[["https://khms0.googleapis.com/kh?v=121\u0026hl=en-US\u0026","https://khms1.googleapis.com/kh?v=121\u0026hl=en-US\u0026"],null,null,null,1,"121"],[["https://mts0.googleapis.com/vt?lyrs=h@199000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.googleapis.com/vt?lyrs=h@199000000\u0026src=api\u0026hl=en-US\u0026"],null,null,"imgtp=png32\u0026",null,"h@199000000"],[["https://mts0.googleapis.com/vt?lyrs=t@129,r@199000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.googleapis.com/vt?lyrs=t@129,r@199000000\u0026src=api\u0026hl=en-US\u0026"],null,null,null,null,"t@129,r@199000000"],null,[[null,0,7,7,[[[330000000,1246050000],[386200000,1293600000]],[[366500000,1297000000],[386200000,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026"]],[null,0,8,8,[[[330000000,1246050000],[386200000,1279600000]],[[345000000,1279600000],[386200000,1286700000]],[[354690000,1286700000],[386200000,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026"]],[null,0,9,9,[[[330000000,1246050000],[386200000,1279600000]],[[340000000,1279600000],[386200000,1286700000]],[[348900000,1286700000],[386200000,1302000000]],[[368300000,1302000000],[386200000,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026"]],[null,0,10,19,[[[329890840,1246055600],[386930130,1284960940]],[[344646740,1284960940],[386930130,1288476560]],[[350277470,1288476560],[386930130,1310531620]],[[370277730,1310531620],[386930130,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1.17\u0026hl=en-US\u0026"]],[null,3,7,7,[[[330000000,1246050000],[386200000,1293600000]],[[366500000,1297000000],[386200000,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026"]],[null,3,8,8,[[[330000000,1246050000],[386200000,1279600000]],[[345000000,1279600000],[386200000,1286700000]],[[354690000,1286700000],[386200000,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026"]],[null,3,9,9,[[[330000000,1246050000],[386200000,1279600000]],[[340000000,1279600000],[386200000,1286700000]],[[348900000,1286700000],[386200000,1302000000]],[[368300000,1302000000],[386200000,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026"]],[null,3,10,null,[[[329890840,1246055600],[386930130,1284960940]],[[344646740,1284960940],[386930130,1288476560]],[[350277470,1288476560],[386930130,1310531620]],[[370277730,1310531620],[386930130,1314843700]]],["https://mt0.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026","https://mt1.gmaptiles.co.kr/mt?v=kr1p.17\u0026hl=en-US\u0026"]]],[["https://cbks0.googleapis.com/cbk?","https://cbks1.googleapis.com/cbk?"]],[["https://khms0.googleapis.com/kh?v=66\u0026hl=en-US\u0026","https://khms1.googleapis.com/kh?v=66\u0026hl=en-US\u0026"],null,null,null,null,"66"],[["https://mts0.googleapis.com/mapslt?hl=en-US\u0026","https://mts1.googleapis.com/mapslt?hl=en-US\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=en-US\u0026","https://mts1.googleapis.com/mapslt/ft?hl=en-US\u0026"]],[["https://mts0.googleapis.com/vt?hl=en-US\u0026","https://mts1.googleapis.com/vt?hl=en-US\u0026"]]],["en-US","US",null,0,null,null,"https://maps.gstatic.com/mapfiles/","https://csi.gstatic.com","https://maps.googleapis.com","https://maps.googleapis.com"],["https://maps.gstatic.com/intl/en_us/mapfiles/api-3/11/0","3.11.0"],[3613555064],1.0,null,null,null,null,0,"",null,null,1,"https://khms.googleapis.com/mz?v=121\u0026",null,"https://earthbuilder.google.com","https://earthbuilder.googleapis.com"], loadScriptTime);  
  };  
  var loadScriptTime = (new Date).getTime();  
  getScript("https://maps.gstatic.com/intl/en_us/mapfiles/api-3/11/0/main.js");  
 })();  

Screen Shot



Tuesday, October 9, 2012

Converting a Managed solution into a unmanaged solution

Today i am just reading the forum and found a good discussion and want to share with you.
Post Link

As we know that we cant make changes in Managed solution but some times we need to customize the solution. Please follow these steps

1. Extract the Solution Zip file.
2. Open solution.xml file in notepad application. Search for Managed Tag (E.g.: <Managed>1</Managed>), Now change the value from 1 to 0.
3.Zip the files again and import it.

That’s it The Solution is changed to Unmanaged. This can be imported and customized as per the need.

Tuesday, July 31, 2012

Xrm.Utility Reference Microsoft Dynamics CRM 2011

New Xrm.Utility Functions in Update Rollup 8 for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online

Microsoft has introduce a new Xrm reference. These functions are available in every application page that supports script.
The functions are below
 
Function
Description
openEntityForm
Opens an entity form
openWebResource
Opens an HTML web resource.

1. openEnityForm
Use to open an entity.

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

Examples:
Open a new account record
Xrm.Utility.openEntityForm("account");
Open an existing account record
Xrm.Utility.openEntityForm("account","A85C0252-DF8B-E111-997C-00155D8A8410");
Open a new account record with a specific form and setting default values
var parameters = {};
parameters["formid"] = "b053a39a-041a-4356-acef-ddf00182762b";
parameters["name"] = "Test";
parameters["telephone1"] = "(425) 555-1234";
Xrm.Utility.openEntityForm("account", null, parameters);
Open a new contact record, move it to the top left corner of the screen, and set the size of the window
Note
You cannot use window object methods such as moveTo or resizeTo in scripts that will run in Microsoft Dynamics CRM for Microsoft Office Outlook.
var newWindow = Xrm.Utility.openEntityForm("contact");
newWindow.moveTo(0,0);
newWindow.resizeTo(800,600);

2. openWebResource

Opens an HTML web resource.

Syntax
Xrm.Utility.openWebResource(webResourceName,webResourceData,width, height)

Examples:
1.     Open an HTML web resource named “new_webResource.htm”:
Xrm.Utility.openWebResource("new_webResource.htm");
2.     Open an HTML web resource including a single item of data for the data parameter”
Xrm.Utility.openWebResource("new_webResource.htm","dataItemValue");
3.     Open an HTML web resource passing multiple values through the data parameter
var customParameters = encodeURIComponent("first=First Value&second=Second Value&third=Third Value");
Xrm.Utility.openWebResource("new_webResource.htm",customParameters);

Note
These values have to be extracted from the value of the data parameter in the HTML web resource. For more information, see Sample: Pass Multiple Values to a Web Resource Through the Data Parameter.
Open an HTML web resource with the parameters expected by HTML web resources:
Xrm.Utility.openWebResource("new_webResource.htm?typename=account&userlcid=1033");
Open an HTML web resource, setting the height and width:
Xrm.Utility.openWebResource("new_webResource.htm", null, 300,300);


Thursday, July 26, 2012

Change the sitemap content programmatically in CRM 2011 (MSCRM)

We can change the content of the sitemap by using the CRM 2011 Webservice.
To accomplish this follow these steps

Step 1: Retrieve the sitemap



QueryExpression query = new QueryExpression();
query.EntityName = "sitemap";
query.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet(true);

EntityCollection col = _service.RetrieveMultiple(query);

Entity sitemap = null;
if (col != null && col.Entities.Count > 0)
   sitemap  = col.Entities[0];

Step 2: Parse the sitemap entity to an XDocument object




string sitemapcontent = sitemap["sitemapxml"].ToString();
XDocument sitemapxml = XDocument.Parse(sitemapcontent);


You can now change the sitemap by modifying the sitemapxml object. After you made your changes, it's time to save these changes.

Step 3: Update the sitemap


sitemap["sitemapxml"] = sitemapxml.ToString();
_service.Update(sitemap);

Step 4: Publish the sitemap

Now you need to publish the sitemap.


PublishXmlRequest request = new PublishXmlRequest();
request.ParameterXml = "<importexportxml><sitemaps><sitemap></sitemap></sitemaps></importexportxml>";
_service.Execute(request);

Helpful links
http://msdn.microsoft.com/en-us/library/gg309259.aspx

Wednesday, July 25, 2012

how to edit expired contract in crm 2011

There is an unsupported method to do this you can do in database table ..contractbasetable and update the statecode and status code column to make it draft again..

(this is unsupported way also test the SQL Update on Dev/Test Environment before running on actual Live Environment)

 
update ContractBase
set StateCode = 0,
StatusCode = 1
where
ContractId = <<YOUR Contract ID>>

Run the above query and when you open your record in crm 2011 it will be draft update the contract and save it.

Thanks and regards

How to add more options in statuscode

Today i am going to tell you an unsupported option to customize statuscode attribute on appointment entity, there's one way you can do it for on-premise setup but because this is the unsupported modifications to the CRM system, I cannot guarantee for any issues due to that modification since I've never done that during any of my development and you may try it with your own risk.

First, you have to modify the statuscode attribute  of the Appointment entity to editable by running the following SQL script on your organization database.

UPDATE  MetadataSchema.Attribute SET Locked = 0
WHERE EntityId IN (SELECT Entityid FROM Entity WHERE logicalname
IN ('Appointment')) 
AND LogicalName = 'statuscode'
 

Then, open the statuscode attribute of the Appointment entity and add more options under Completed and Canceled status.

Retrieve a lookup field value in a Silverlight page as a WebResource in CRM 2011


To retrieve the values  of  a lookup field  or any other field in a  silverlight page, we need to  follow  two steps  i.e
1. Design the  silverlight application  to  retrieve the lookup field value.
And create  a web resource of type silverlight and upload the .xap file.
2. Create  a  webresource in the form customization area and pass the  field name whose value is needed in the silverlight page as  a parameter in the "custom parameter" area and point  to the web resource created in  the step 1.


We  need to  modify the  Application_startup method to captture the parameter  passed from the CRM controls,
Now  in  the Mainpage.xaml.cs we will get  a hold on  CRM object and retrieve the  value of the parameter that  we have passed as below,

dynamic xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");

var fieldName = Application.Current.Resources["InitParm_data"];

// for getting primary contact lookup field

var numAttr1 = xrm.Page.data.entity.attributes.get(fieldName).getValue()[0].id;

In the  same  way  we  can retrieve  different other fields.

we can also set the crm field values from within the  silverlight application  as  below,

dynamic xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
var numAttr = xrm.Page.data.entity.attributes.get("ser_noofusers");//ser_noofusers is  a custom field numAttr.setValue(Math.Round(slider1.Value, 0));

I hope it helps some one

Tuesday, June 26, 2012

CRMSvcUtil.exe parameter is incorrect

Today i have got a strange message while creating early bind class code even i have entered correct parameters in command line.
error: Parameter is incorrect
I have use following command
CrmSvcUtil.exe /url:https://myorg.crm.dynamics.com/XRMServices/2011/Organization.svc
    /out:GeneratedCode.cs /username:"myname@live.com" /password:"myp@ssword!" 
Which is correct.
Then i got a solution and decided to share with you
go to the below location
C:\Users\Mubasher(your username)
and delete the folder
LiveDeviceID

Run the above command again.
I hope it helps you. Please share your experience in comments.
For more help on CrmSvcUtil.exe Extension Usage and Command-Line Parameters please check the following link
http://msdn.microsoft.com/en-us/library/gg695820.aspx

Saturday, June 9, 2012

How to Display a Report in a Dashboard in Dynamics CRM 2011?

There are a lot of reasons to display a Report within a Dashboard. And i have decided to write my own blog for this purpose And take help from this blog. So today i am sharing the steps so you can do it on your project too.
1. Run the report you want to display in a Dashboard.
2. Press F11 Copy the URL that displays in address bar
3. Create a New Dashboard. Chose any layout that fits in your requirement
4. Insert an IFRAME in the Dashboard.








5.  Paste the above Url after making the following adjustments to it:
  • Remove “http://myservername/myorgname” . This will make your url relative.
  • Replace “?action=filter” with “?action=run”. This will bypass the first step before running the report where CRM asks for some parameters.
for instance, if the original url was:
http://crm-vm222/MyOrg222/crmreports/viewer/viewer.aspx?action=filter&helpID=My%20Report%20Name.rdl&id=%7bE70C6DCA-31FF-E011-807F-CCCC293AE41E%7d
..then, you should write:
/crmreports/viewer/viewer.aspx?action=run&helpID=My%20Report%20Name.rdl&id=%7bE70C6DCA-31FF-E011-807F-CCCC293AE41E%7d

6. Also, clear checkbox ‘Restrict cross-frame scripting’ . At least in my case I had to do that to make it work.



7. Use the buttons ‘Increase Width’ and ‘Increase Height’ so as to make the IFRAME fill the whole page of your Dashboard (or just the space it’s supposed to need).


8. Save & Close the Dashboard.
9. Publish the Dashboard.
10. Try It! :) . After publishing make some minor changes like size / layout depending upon your requirement.But our main pupose has been achieved which is displaying the report.
Hope it helps,

Friday, June 8, 2012

How to remove a primary field of the lookup view in MS CRM 2011

Hi All.
Some people wants to remove primary field from lookup view. This is a system column and cannot be removed in a supported manner you could just set its width to minimum.


There is only one unsupported customization available for this

1. Export Your entity.
2. Open customization XML.
3. Find Your Lookup View from XML.
4. Remove the desired field from view.
5. Save and import customization.xml to CRM.
6. Publish your entity.

Note: This is unsupported customization.


How to set Option set value to null CRM 2011


Option set does not accept NULL to clear its value so you need to write the code like below

function clearOptionSetValue()
{
var Prioritycode = Xrm.Page.data.entity.attributes.get("prioritycode");
Prioritycode.setValue(null);
}

Friday, May 18, 2012

The Extensibility Model of Microsoft Dynamics CRM

The extensibility platform is the best feature of Dynamics CRM and Dynamics CRM online. The application that we develop is on the top of this platform dynamics CRM support two type of deployments Dynamics CRM (on-premises) and CRM online(Hosted). Dynamics CRM has a security model that protects the platform from unauthorized access on the web.
Every application that developed for Dynamics CRM server is uses Web service to communicate with the xRM platform layer. Microsoft Dynamics CRM uses a metadata driven architecture to provide the flexibility to create custom entities and additional system entity attributes and also make upgrades and transportation of solutions easier.
We can control access to data through security using xRM platform, controls access to the database, and raises events for workflow processes and custom business logic implementations (plug-ins). The platform layer provides for both incoming and outgoing email processing though Microsoft Exchange Server.

 WCF Web Services

Microsoft Dynamics CRM uses web service interface to interact with CRM data, meta data and with platform services, The web services are based on Windows communication Foundation (WCF). We could use write application and tools with the help of these web services. For more information about Web services, see Write Code for Microsoft Dynamics CRM (Web Services). For more information about Web services, see the .NET Framework Developer Center. You can also read the article XML Web Services Basics.

Processes (Workflows)

Most of us are familiar with workflows in 4.0 but in 2011 Microsoft introduces processes. Which include two categories workflows and dialogs. Processes are used to create and execute custom business processes. As you can see in the above picture process are on top of WWF. We can write custom process activates (.Net assemblies). For more information about processes, see Processes in Microsoft Dynamics CRM (Formerly Workflows).

Plug-ins

Microsoft gives us extension to perform custom business logic. You can implement your business logic not just with the help of workflow process but also with the help of Plug-ins
Plug-ins support an event handler interface that is based on a pipeline execution model. The pipeline model allows for event handlers, also known as plug-ins, to be executed before or after the core operation of the system. When an action occurs caused by user interaction with the Web application or a Web service call, the platform checks for registered event handlers. If a handler is registered for notification, the platform executes a well-defined event handler method, passing it run-time information. For more information, see Plug-ins for Extending Microsoft Dynamics CRM.

Client Application Extensions

MS CRM has a very power client application extensions. We could implement customization and all the client programming code is stored in the MS CRM database. This makes easy to import and export the code from developemt enviorment to production enviorment.
Reporting
Using SSRS and built in report creation functionality we could develop complex reports.
There are two catagrioes of reports
1.      SSRS
2.      Fetch XML
We could directly export our report for Excel and access.