Monday, December 19, 2011

CRM 2011 Dialog guide

Hi, one of my favorite new features of CRM 2011 is Dialogs! This is more of a interactive workflow where the user gets guided thou a prosess.

To explain Dialogs, I've created a simple use-case: This is part 1 out of x !? ;)
I have a lot of leads and want to create a custom lead convert.
1. I want to check if the lead have a company allready in CRM as an account
2. I want to check if it exists two leads against same company
- + You could add more checks

So let's get dirty and create this dialog :)

First thing first:
Start by planning the keyelements you'll be needing in this Dialog.
1. We'll going to need two queries.
  • Find all Accounts that might be a duplicate.
  • Find all Leads that might be the same company.
2. The steps we're going to need are:
  • Build up Queries
  • Check the Queries
3. Have a basic thought of the logic under each step:
Build up Queries
  • Find all Accounts where: Accountname in Accounts entity equals/contains Company field in selected lead
  • Find all Leads where: Company field in selected lead equals/contains company field in other leads
Check the Queries
  • If  the query "Find all Accounts that might be a duplicate." contains more then zero records AND the query "Find all Leads that might be the same company." contains more then one recod. (Since we running dialog on one of them)
    • Promt user and ask what to do
  • Else if:
    • "Find all Accounts that might be a duplicate." contains more then zero records
      • Promt user and ask what to do
    • "Find all Leads that might be the same company." contains more then one record
      • Promt user and ask what to do
  • Default:
    • Promte user and tell no duplicates or other leads are found, ask what he wanna create:
      • Create Account: Yes/No
      • Create Contact: Yes/No
      • Create Opportunity Yes/No
    • if Create Account equals yes
      • Start Child Dialog "Create Account"
    • if Create Contact equals yes
      • Start Child Dialog "Create Contacs"
    • if Create Opportunity equals yes
      • Start Child Dialog "Create Opportunity"
The reason why it's important to have a basic drawing of these steps and if's are that it's hard/impossible to re-design the dialog when first started. (You can't re-design the logical hierarki)

Let's build this Dialog! I've created a videoguide as I'm to lazy typing down every detail and taking lots of screenshots :P

Part 1:
Creating the basics for the dialog:
(Note I'm doing one error! The IF ("Find all Leads that might be the same company." contains more then one record. I'll correct the error in next part!)
Part 2:
Creating the default action (Normal convert)
Part 3:
Creating the what will happen if "Find all Leads that might be the same company." contains more then one record
Part 4:
Creating the what will happen if "Find all Accounts that might be a duplicate." contains more then zero records

Part 5:
Creating the what will happen if "Find all Accounts that might be a duplicate." contains more then zero records AND the query "Find all Leads that might be the same company." contains more then one recod.
Good luck devoloping futher!!

Sunday, December 11, 2011

A few must have Tools for CRM 2011

Hi, I'm sorry is been a lot to do at work the past few weeks, so few updates :( But here comes a nice one, a list of nice tools for MS CRM 2011 with a short description:
http://pragmatoolkit.codeplex.com/
It provides easy user interface to create custom buttons and add to CRM Ribbon without having to manually modify the underlying XML files. It also takes care of creating the solution and publishing it back to MS CRM 2011.
http://jswebresourcemanager.codeplex.com/
JavaScript Web Resource Manager for Microsoft Dynamics CRM 2011 helps CRM developers to extract javascript web resources to disk, maintain them and import changes back to CRM database.
You will no longer have to perform mutliple clicks operation to update your js web resources
http://crm2011odatatool.codeplex.com/
The CRM 2011 OData Query Designer is a Silverlight 4 application that is packaged as a Managed CRM 2011 Solution. This tool allows you to build OData queries by selecting filter criteria, select attributes and order by attributes. The tool also allows you to Execute the query and view the ATOM and JSON data returned.
http://crm2011metabrowser.codeplex.com/
The CRM 2011 Metadata Browser is a Silverlight 4 application that is packaged as a Managed CRM 2011 Solution. This tool allows you to view metadata within CRM including Entities, Attributes and Relationships.
http://roleupdater.codeplex.com/
Role Updater for Microsoft Dynamics CRM 2011 makes it easier for CRM 2011 administrators and developers to add or remove privileges to multiple security roles in one operation.
You'll no longer have to open each security role and apply privileges one by one.
- This application is compatible with OnPremise, Online and Claims based authentication deployments

Hope these tools give you an early Chrismast vecation by saving you some time :)

Thursday, November 24, 2011

Several basic Javascript commands CRM 2011

Case switch:
var valueToSwitch = Xrm.Page.getAttribute("yourField").getValue();

switch(valueToSwitch)
{
case 0:
//what to do if value = 0
break;
case 1:
//what to do if value = 1
break;
case 2:
//what to do if value = 2
break;
}
 Catch error:
try {
//Code
}
catch (ex) {
var txt="You got the following error\n\n" + ex;
alert(txt);
}
Force submit (fields that are marked read only - make scripts able to write to them)
Xrm.Page.getAttribute("youField").setSubmitMode("always"); 
 Forminfo check:
function forminfo()
{
var items = Xrm.Page.ui.formSelector.items.get();
if (items.length > 1)
{
alert("Formtype: " + Xrm.Page.ui.getFormType());
alert("Form ID: " + Xrm.Page.ui.formSelector.getCurrentItem().getId());
alert("Formname: " + Xrm.Page.ui.formSelector.getCurrentItem().getLabel());

else
{
alert("There is only one form item currently available.");
}
}
 Maximize window
window.top.moveTo(0,0);
window.top.resizeTo(screen.width, screen.height);
 Get name of selected picklist value
Xrm.Page.data.entity.attributes.get("crayon_fagomrde").getText();
 Start Dialog from Form (note tings to change)
var dialogId = "a13ad982-d812-40a0-ab67-f314cdabbd2b"; // This must be your Dialog ID
var returnValue = showModalDialog("/" + Xrm.Page.context.getOrgUniqueName() + "/cs/dialog/rundialog.aspx?DialogId=%7b" + dialogId + "%7d&EntityName=account&ObjectId=" + Xrm.Page.data.entity.getId());

//Optional:To save and close entity form as soon as the dialog is closed.
//Xrm.Page.data.entity.save("saveandclose"); 
 Set URL to Iframe
var url = http://www.crayon.com
Xrm.Page.getControl("IFRAME_iFrameName").setSrc(url); //("about:blank") if black
 This was some of the basic javascripts..

Hope it's usefull for you!

Thursday, November 17, 2011

66x48 Icons CRM 2011.. Yes? No?! Why?

Did you know that 66x48 icons in CRM 2011 isn't used? Could this be becourse of backwards compatibility when organizations are upgraded from Microsoft Dynamics CRM 4.0? Anyway, here's some details about Icons:

Types of Icons

The following table list is the types of entity icons you can update.

    Type Specifications Property
Icon in Web application
Displays when records for this entity are displayed in a grid.
  • 16x16px
  • Less than 10k
IconSmallName
Icon for Entity Detail Forms
The application incorrectly labels this as the Shortcut icon in Microsoft Dynamics CRM for Microsoft Office Outlook
  • 32x32px
  • Less than 10k
IconMediumName
This size icon is not used in Microsoft Dynamics CRM 2011. The application incorrectly labels this as the Icon in Entity forms.
  • 66x48px
  • Less than 10k
IconLargeName

PNG Web resources are recommended because they support transparency and good compression with a better color fidelity than GIF. GIF, JPG, & ICO formats are supported for backwards compatibility when organizations upgrade from Microsoft Dynamics CRM 4.0.

Illustration of where to upload Icons:
(Shows up when a entity is selected)


If you are using CRM 4.0 - Check out the Demonstration Tools - Contains a "Icon creation tool" I simply loved!

Get the great feeling of not have a customized CRM solution by adding Icons

Tuesday, November 15, 2011

CRM 2011 server sloooooooow?

Have you checked you SQL memory usage? Do you have several applications running against the same SQL server? Are you using SQL 2008? well, then you realy should check the following:
  • What kind of settings are set for memory usage for each application instance in the SQL?
g.ex: you're using SharePoint and CRM on the same SQL server, and total have 8GB memory on the SQL server.(This does NOT inc the CRM server and SharePoint server).

What should I think of?
- Number of users at once on each application.
- The requirements and usage of each application
- +++ other factors

Good rules: (This is ONLY an example. It's almost imposseble to say what's good for your enviorment)
  1. Always let the OS have some memory. (Let's say 1,5GB) - 6,5GB left
  2. Calculate how much memory to give CRM and SharePoint (in this case)
    • Rember to think of application usage and number of users online at same time.
    • NOTE (Often the memory usage get's Multiplyed with ca 1,5 from the max if server gets stressed)
    • God practis is operating with 1024MB, so if we want 2GB we give 2048MB memory
    • Let's say we give the CRM server 3072MB and SharePoint 3072MB
      • (Do not foreget the 1,5 factor!!)
  3. Set the max and min Memory for each application instance in SQL:
    1. Go to: SQL Manager > The SQL instance > Properties > memory
    2. (Make sure services and no users are using system)
(How to find memory setings pr SQL application instance)

If your setings are setup like this: You should consider changing the SQL memory settings. Default "Next, next, next install setings"!
(How to "eat" all memory on SQL. hehe...)

Adjust the max and min memory usage as calculated

(How to adjust the memory)

This is what happend when the memory is adjusted:
(SQL response faster, and memory usage lower)

Again, this is an example you'll have to figure out the correct numbers and settings yourself based on enviorment and numbers of users! Tip: If you use virtual SQL server; check your networkcard setings for TCP/IP aswell! ;)

Hope this gives you some tips on how to get faster response from SQL to Your CRM 2011!

Sunday, November 13, 2011

How to Hide Top Bar, Ribbon, Quick Launch in SharePoint 2010?

Ribbon, Top Bar and Quick Launch comes up with Application Pages by default. If you want to open the page in Dialog Framework then those elements will take more space and confuse the enduser. You can remove these elements by creating new page layout which is time consuming.

There is other ways to hide these controls. One simple way is by passing a Parameter with the URL. [&IsDlg=1]
Under I'll show an example of SharePoint 2010 viewed in iFrame CRM 2010..
function setturl()
{
//Field with URL - Field have to be created first 
if(Xrm.Page.getAttribute("prefix_url").getValue() != null){
/*
//Remove "Documents botton" in default CRM 2010
var crmNavBar = "navDocument";
var tdAreas = "_NA_Info";
document.getElementById(crmNavBar).parentElement.style.display = "none";
document.getElementById(tdAreas).parentElement.parentElement.parentElement.parentElement.colSpan = 2;


//Show a custom "Document tab" - Have to be created first
Xrm.Page.ui.tabs.get("docs").setVisible(true);

*/ 
var accountURL = "Insert you default URL for SharePoint server ink the libarary name - End it with /";
// example SharePoint 365 Online: "https://testcompany.sharepoint.com/DMCRM/account/Forms/AllItems.aspx?RootFolder=%2FDMCRM%2Faccount%2F

//The relative URL. Is the folder in the libary entert in accountURL 
var relativ = encodeURI(Xrm.Page.getAttribute("prefix_url").getValue());
//example: test%20company%2F

//Remove Ribbon, Quick luch top bar  
var removeSPmenu = "&IsDlg=1"

//Re-create URL with SharePoint site content only.   
var newURL = (accountURL + relativ + removeSPmenu);
//alert("The new URL: " + newURL);
//example test alert: The new URL:
https://testcompany.sharepoint.com/DMCRM/account/Forms/AllItems.aspx?RootFolder=%2FDMCRM%2Faccount%2Ftest%20company%2F&IsDlg=1

//iFrame on form called "iframe_docs" get's new URL
Xrm.Page.getControl("IFRAME_docs").setSrc(newURL);
}
}
SharePoint will hide these elements when It gets IsDlg Parameter on URL.

This only work in SharePoint 2010, but then showing SharePoint 2010 via iFrame in CRM 4.0/CRM 2011 this trick is very handy!
But every time we can't pass these parameters. This is when you'll have to edit the CSS code in the Application Page under PlaceHolderMain scetion:
  
<style type="text/css">
#s4-ribbonrow, .ms-cui-topBar2, .s4-notdlg, .s4-pr s4-ribbonrowhidetitle, .s4-notdlg noindex, #ms-cui-ribbonTopBars, #s4-titlerow, #s4-pr s4-notdlg s4-titlerowhidetitle, #s4-leftpanel-content {display:none !important;}
.s4-ca{margin-left:0px !important; margin-right:0px !important;}
</style>

This will hide the Ribbon, Top Bar and Quick Launch and only show the content.

Note : If you use this code in SharePoint Site Pages with Content Editor Webpart then you can't check in the page since the toolbar goes hidden.

If you still want to use this code on Site Pages then add Content Editor Webpart and paste the above code. When you want to make other changes then open the page in browser with parameters [ ?Contents=1 ] which opens the page in WebPart maintenance mode. Remove the content editor webpart and re-open the page. Make the changes and add content editor webpart at last along the CSS Code. To check in the page use Site Pages Library.

Hope you found this tip usefull! :)

Thursday, November 10, 2011

"Start-Up - Script" for MS CRM 2011

This script can contain every aspect of scripting with only one trigger point. It also checks the FormType state for "Create", "update" and so on.. This javascript is used by many people already, but I've updated it with "onchange" aswell:

The only thing you'll have to do is: Add this as a webresource to the entities Form that needs javascript. and add the function "OnCrmPageLoad" to the "Form OnLoad" tirgger point!
/* Script Entry Point */
function OnCrmPageLoad() {
var FormTypes =
{
Undefined: 0,
Create: 1,
Update: 2,
ReadOnly: 3,
Disabled: 4,
QuickCreate: 5,
BulkEdit: 6
}
runAlways();
switch (crmForm.FormType) {
case FormTypes.Create: OnNewFormLoad(); break;
case FormTypes.Update: OnUpdateFormLoad(); break;
case FormTypes.ReadOnly: OnReadOnlyFormLoad(); break;
case FormTypes.Disabled: OnDisabledFormLoad(); break;
case FormTypes.QuickCreate: OnQuickCreateFormLoad(); break;
case FormTypes.BulkEdit: OnBulkEditFormLoad(); break;
case FormTypes.Undefined: alert("Error"); break;
}
}
/* Implement each Form Type you wish to address */
function runAlways() {
onchange(); //Loads all fields that should have onchange functions on them
}
function OnNewFormLoad() {}
function OnUpdateFormLoad() {}
function OnReadOnlyFormLoad() { }
function OnDisabledFormLoad() { }
function OnQuickCreateFormLoad() { }
function OnBulkEditFormLoad() { }
/* --------------- Below is all the Private Functions ---------------------*/
function onchange(){
Xrm.Page.data.entity.attributes.get("prefix_fieldname").addOnChange(examplefunction);
}
function examplefunction(){
alert("Hello World");
}
Hope you like this script! It's one of the "life saving" scripts for CRM 2011
(it's also avaiable for MS CRM 4.0)
- Happy Scripting!


My first blog post - Intro!

Hi, I'm going to share some of my experience on CRM and SharePoint on this blog. Hope you'll enjoy it and in best case get something usefull out of it :)

So Over to the important stuff: Writing My first CRM 2011 tick. It'll will very soon show up! Stay tuned!