Tuesday, December 25, 2012

CRM 2011 - Existing Products Look up Field Behavior

CRM 2011 - Existing Products Look up Field Behavior

The link below is the solution to the problem where you want only the products of the selected price list to be displayed but you get all the products listed.

One thing to note though, your code on the change event of the existing product field will cease to function. You will have to find alternate locations / triggers on the form to get the code going. Tough decision though.

http://blogs.msdn.com/b/apurvghai/archive/2012/02/15/exisitng-product-lookup-lists-all-the-products.aspx

Re-creating the page just in case:

This article talks about a parent look view which is never visible after the “Display search box in lookup diaglog” is checked while customizing Opportunity Product Entity in CRM 2011. There is an easy workaround to get back to old view. I have mentioned the ways you see this happening and a tweak in customization which will revert this back.

How can I see a different view?

  1. Go to Settings > Customizations > Customize the system > Entities > Opportunity Product > Forms > Main Form > Existing Product
  2. Select "Change Properties"
  3. Go to General Tab and scroll down until you find “Display this is search box”
  4. Check that setting and save the entity following to publish it.
  5. Now go to, opportunities entity
  6. Add a price list and continue adding an existing product
  7. A screen will appear to choose existing product.
  8. The moment you click lookup icon, you will see that the name of view has changed to “Product Lookup View”

How do I revert to old view?

If you’re thinking that you can just go and uncheck. No then that’s not a solution. We will need to revert through a customization tweak. The reason for this and by now CRM has reset the view id. Hence it shows a different view. 
The following are steps to achieve that
  1. Go to Settings > Solutions
  2. Add new Solution and provide a valid name to it.
  3. Save the solution.
  4. Now add existing entity, “Opportunity Product”
  5. Export the solution as unmanaged
  6. Open the unmanaged solution in notepad and locate the following:
  7. Replace {8BA625B2-6A2A-4735-BAB2-0C74AE8442A4} with {BCC509EE-1444-4A95-AED2-128EFD85FFD5}
  8. Save the changes
  9. Zip the files and import the solution back to your environment
  10. Publish the customizations
  11. Refresh the CRM in your browser
  12. You will see the correct view.
You can always check the correct GUID values in the database. 

Happy customizing :) 

Saturday, December 1, 2012

How to Set Up Pre-Filtered Lookup Fields in CRM 2011


8 Steps to Pre-Filter Lookups in Microsoft Dynamics CRM 2011

As I begin my fourth Microsoft Dynamics CRM 2011 implementation, I find myself using one of the lesser-known new features of this version of CRM over and over again. In all of the previous versions of Microsoft CRM, implementers have had a need to ‘pre-filter’ lookups and picklists, or build dependent picklists. Now, in CRM 2011, we are able to do just that! To utilize this heavily, it does require some planning to ensure that you are not creating too many unnecessary entities or tables in CRM, but when you do your planning, this feature will become very useful.
Let’s take a simple example – we have Categories and Sub-Categories for our Leads and Accounts. From a User-Interface perspective, we want the User to enter the Category, then click the lookup for Sub-Category and get some specific results in that list that are pre-filtered based on what was chosen in the Category field. Creating this pre-filtered lookup and maintaining the parent-child hierarchy or definition for the filtering is all out-of-the-box functionality now in CRM 2011. In the past, this type of functionality could be achieved, but would be many, many lines of javascript that was difficult to maintain or change, especially when you turn over the CRM implementation to the client. These pre-filtered lookups can also be several levels deep, whereas before that was very difficult to maintain via javascript.

Step 1:

Here’s how you set up these pre-filtered lookups for the Lead Entity. First, create the first new entity by going to Settings → Customization → Customizations → Customize the System. Now click New → Entity to create a new Entity in CRM 2011.
Next, refer to the image below for the settings to create the new entity (this is for my Category Entity example):
Create a new category entity in CRM 2011
Image 1 – Create new Category Entity
**Note: I always add custom entities to the Settings Area so that you easily view the entity records, and in this case, add Categories to CRM.
**Note: There is no need to make this entity anything more than a lookup table, so there is no need, most of the time, for these other options (mail merge, notes, activities, etc.). Please evaluate these options for your individual situation as there could be instances that these options are required, but not in my example.

Step 2:

Now Save the entity and we will add the relationships from this new Category Entity to the Lead entity. On the left-hand side of the new Entity definition screen, click on 1:N Relationships. Then click “New 1-to-Many Relationship,” which is where we will add the new relationship to the Lead. Fill out the form as in the image below.
Create 1:N Relationship between category & lead
Image 2 – Create new 1:N Relationship between Category and Lead
A couple of things I want to point out:
  • For the relationship definition ‘Name’, by default, the relationship name is new_new_category_lead, and I always remove the duplicate ‘new_’ from the name so that it becomes new_category_lead.
  • For the lookup field ‘Name’, by default, it concatenates “id” to the end of the name, and I always leave this so that if I am writing reports or integrations, I will know that the field is a lookup field.
  • This type of relationship should be referential as a category is not truly a ‘parent’ to a lead, and I think of it in these terms, if the primary entity (in this case category) is deleted, should all related entity records (in this case leads) be deleted as well (one cannot exist without the other)? In this case, that is not true, so referential is the correct relationship behavior.

Step 3:

Next, Save and Close the Category Entity in CRM 2011 and navigate to the Lead Form within the Default Solution by going to Components → Entities → Leads → Forms → then double-click the ‘Main’ Form. Now drag the new ‘Category’ field onto the Form where you would like for it to appear. Save and Publish the Lead Form. Now you have created the first lookup field which will determine the values that appear in the second lookup field.

Step 4:

The next step is to create the second custom entity, Sub-Category. Repeat steps 1 through 3 above, just replacing Sub-Category for Category. Once you have added the Sub-Category field to the Lead form and published it, we are ready to configure the pre-filtering.

Step 5:

Now we will add a Category lookup to the Sub-Category form. This is how we will define what Sub-Categories appear for which Categories. Within the Default Solution, navigate back to the new Sub-Category Entity (Components → Entities → Sub-Category → N:1 Relationships) and click “New Many-to-1 Relationship.” Now we will tie Categories to Sub-Categories in order to filter. Fill out the form as in the image below.
Create new N:1 Relationship sub-category & category
Image 3 – Create new N:1 Relationship between Sub-Category and Category

Step 6:

Now go to the Sub-Category’s Main Form and add the new, required Category field to the form, as shown in the image below. Save and publish the changes.
Sub-category form customizations in MS CRM 2011
Image 4 – Sub-Category Form Customizations

Step 7:

The last step in the configuration process is to actually add the pre-filtering to the sub-category field on the Lead Form. This is where we will tell CRM 2011 to pre-filter the sub-category field based on the category chosen on the Lead. Navigate to the Lead entity Form (Components → Entities → Lead → Forms) and open the ‘Main’ form. Once the Form is open, double-click on the Sub-Category field where we will set its properties. Configure the Related Records Filtering options as in the image below.
Setting sub-category pre-filtering on lead form
Image 5 – Setting Sub-Category Field Pre-Filtering Properties on Lead Form
**Note: you can choose whether you would like to restrict the user to choosing only Category and Sub-Category combinations that you have defined (leave ‘Allow users to turn off filter’ unchecked) or you can allow Users to choose any combination and leave the pre-filtering just as a default, but not a hard requirement (in that case, you would check the ‘Allow users to turn off filter’ box).
**Note: For now, leave the Additional Properties as-is. I will touch on this in another post.

Step 8:

Now click OK and Save and Publish the Lead form. The last step is to go into Microsoft Dynamics CRM 2011 and add the Categories and Sub-Categories to CRM. I typically would add all top-level Categories to CRM 2011 first (for the new entities to show up in Settings, you will need to refresh CRM (push F5), then navigate to Settings → Extensions → Categories. Add all of the new Categories necessary. When you are finished, go to Settings → Extensions → Sub-Categories and add all of your Sub-Categories (remember for each Sub-Category, you must also enter a Category – this is how we define the pre-filtering!). When you have finished adding your data to CRM, open up a Lead and test out the pre-filtering to ensure you are getting the expected results! Now if you wanted to add this same functionality to the Account or any other entity in CRM 2011, just repeat these steps to create the relationships with other entities!
Original article here.

Sunday, June 10, 2012

Mapping MSCRM fields from Opportunity Product to Quote Product

Mapping MSCRM fields from Opportunity Product to Quote Product

MSCRM has an oversight in the default Opportunity-Quote-Order process in taking fields entered at the Opportunity Product stage and having these mapped to any resulting Quote Product or Order Product records.
This means that any fields (such as the field we added to the Opportunity Product screen to track the Product Number of the Product entered from main post in this category) are not mapped over to the resulting Quote Products on our Quote.
Opportunity Products
List of Opportunity Products
Quote Products
List of Quote Products mapped from an Opportunity
This obviously would be confusing to the end-user!
However whilst MSCRM does not directly list the relationship between a Quote Product and Opportunity Product within the available Customisation User Interface – this relationship (and crucially it’s Mappings) are available to us.
The following steps allow us to add or remove mappings to this relationship, and ensure that our custom Product Number field is mapped across.
STEP 1 - Run a SQL Query against the MSCRM Database (typically X_MSCRM where X is your Organisation Name for the MSCRM Deployment) to determine the GUID Id of the Relationship between the Quote Product Entity and the Order Product Entity.
1SELECT  EntityMapId
2FROM    EntityMapBase
3WHERE   TargetEntityName='quotedetail' AND SourceEntityName='opportunityproduct'
STEP 2 – Take the output of this SQL Query and insert this into the following URL:
1http://[x]/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=[y]
Where [x] is the URL address of the MSCRM Deployment in question and [y] is the GUID Id output of the SQL Query
STEP 3 – This will present the Relationship Mapping screen for mapping attributes from the Opportunity Product entity to the Quote Product entity:
Relationship Mappings from Opportunity Product to Quote Product
Relationship Mappings from Opportunity Product to Quote Product
From here, any number of mappings can be added to define how the Products attached to an Opportunity are mapped across when a Quote is added to the Opportunity. (obviously any changes or additional mappings will need to be published in usual MSCRM fashion)
The same steps can also be used for controlling how fields are mapped across from Quotes to Orders in a similar fashion:
1SELECT  EntityMapId
2FROM    EntityMapBase
3WHERE   TargetEntityName='salesorderdetail' AND SourceEntityName='quotedetail'
And similarly how fields are mapped from Order Products to Invoice Products:
1SELECT  EntityMapId
2FROM    EntityMapBase
3WHERE   TargetEntityName='invoicedetail' AND SourceEntityName='salesorderdetail'
This is a useful technique when working with any custom fields in a Opportunity-Quote-Order process in MSCRM.

Sunday, October 2, 2011

Modifying Quote Templates in CRM 2011

Since we all don’t work for Adventure Works, Inc., organizations that use the quote entity to send quotes to customers will ask their administrators to modify the out-of-the-box quote template. It’s not as straight-forward as it seems and you could easily corrupt the original mail merge template so I wanted to give instructions to help you along.
Standard instructions will probably tell you to click on ‘Settings’, ‘Templates’, ‘Mail Merge Templates’, then change the view to see all templates and double-click the template you wish to modify.
clip_image002
clip_image004
Yes, you can go about it this way, but editing the mail merge template is certainly an iterative process so I’m going to suggest go to another location to modify your templates. By going to the quote entity and opening a quote, you save some steps as you save your changes and then run through the mail merge of the quote to see how they look. So with a quote open, do the following:
1. Click on the ‘Print Quote for Customer’ button.
clip_image006
2. Select the type of mail merge template document and click the lookup icon. (I suggest using one ‘Organizational mail merge template’ to insure uniformity in the documents you send out to your customers.)
clip_image008
3. Select the out-of-the-box template named, “Quote for Customer”, and click ‘Properties’.
clip_image010
4. The following window will pop up. Click ‘Edit Template in Word’.
clip_image012
5. Next, click ‘Open’.
clip_image013
6. Microsoft Word will open.
a. If you are using Word 2010 it is very likely you will see the following across the top of the screen. Click ‘Enable Editing’.
clip_image015
b. Next, you may get prompted by another similar message. Click ‘Enable Content’.
clip_image017
7. The document tells you, “To start the mail merge, click CRM.” However, you actually need to click on the ‘Add-Ins’ menu item and click ‘CRM’. Note: Depending on the version of Word you have, you may have to click ‘Mailings’ or ‘Add-Ins’ to get to the ‘CRM’ button.
clip_image019
8. Next, the following screen will pop up. Click ‘OK’.
clip_image021
9. Now you can begin to edit your template.  If it looks like the screenshot below, hit ‘Alt+F9’.
image
It will display more of the editable areas of the template.
clip_image023
Below, outlined in green, are changes I made to the logo, the address tables and at the bottom of the template. Along with the ability to remove merge fields using the delete button, you can add merge fields by clicking the ‘Insert Merge Field’ button on the ribbon, outlined in blue with the arrow pointing to it. Lastly, I suggest avoiding making changes in the section outlined in red unless you absolutely must. This is where the quote product data is entered and calculations take place. I don’t see a need to edit this section.
clip_image025
10. Upon completing your changes, click on ‘File’, ‘Save As’.
IT IS OF THE UTMOST IMPORTANCE THAT YOU CHOOSE ‘SAVE AS’ INSTEAD OF ‘SAVE’ TO AVOID OVERWRITING AND CORRUPTING YOUR ORIGINAL MAIL MERGE TEMPLATE!!! You may ask why we don’t save a copy of the template before we start any of this. The problem with that is the original file is a “.doc” file and if you make a copy of it, all of the back-end functionality of the mail merge is lost.
You’ll notice that it will save the file as “.xml” instead of a “.doc” file, which is the type of your original template. Be sure to save it as an XML file.
clip_image027
11. Now go back and repeat steps 1 & 2 to get to the screen below where you can choose your template except this time click on ‘New’.
clip_image029
12. The following window will pop up. Fill in the information outlined in red. Then browse for your newly saved template and click ‘Attach’.
clip_image031
13. Once the screen refreshes, you’ll notice your file name changed to blue. You will also have a new button called ‘Actions’ on the menu bar. In that menu, select ‘Make Available to Organization’ to make your template viewable by everyone. And fear not, once you make it available to the organization, you can always go back to ‘Actions’ and click the ‘Make Personal’ menu item to make it just yours again.
clip_image033
14. You’ll end up back at this screen. Choose your new mail merge template and click ‘OK’.
clip_image035
15. Click ‘OK’ at the next screen.
clip_image037
16. Microsoft Word will open.
a. If you are using Word 2010 it is very likely you will see the following across the top of the screen. Click ‘Enable Editing’.
clip_image038
b. Next, you may get prompted by another similar message. Click ‘Enable Content’.
clip_image039
17. The document tells you, “To start the mail merge, click CRM.” However, you actually need to click on the ‘Add-Ins’ menu item and click ‘CRM’. Note: Depending on the version of Word you have, you may have to click ‘Mailings’ or to get to the ‘CRM’ button.
clip_image040
18. Next, the following screen will pop up. Click ‘OK’.
clip_image042
19. Click on ‘Next: Preview Your Directory’ in the lower, right corner of the Word window.
clip_image044
20. Click on ‘Next: Complete the merge’ in the lower, right corner of the Word window.
clip_image046
21. Click on ‘To New Document…’ in the top, right of the screen.
clip_image048
22. Click ‘OK’ at the next pop up screen.
clip_image049
23. And behold the culmination of your hard work!
clip_image051
Don’t be surprised if you don’t get everything looking right the first time. In that case, go back and repeat steps 1 – 10, but this time be sure to edit the new mail merge template you created instead of the original. Next, repeat steps 1 – 3. In step 4, remove the old file from the bottom and attach the new file you just created. I name my files with an incremental number after each one as I develop the quote in case one of my attempts ends up rendering the template inoperable. So in this case, I would replace the file “CustEffective Quote.xml” with “CustEffective Quote1.xml”. Repeat this last paragraph as many times as needed to get your quote looking beautiful.

Tuesday, September 27, 2011

Generating Quotes in Microsoft Dynamics CRM 2011

Creating quotes, orders, and invoices in Microsoft Dynamics CRM 2011 is easy and very useful.  Once an opportunity has been created and you have established your product catalog in the system, generating a customer quote is simple and can be done in 6 short steps.
Follow these 6 short steps to quickly create a customer quote in Microsoft Dynamics CRM 2011:
Step 1: Start by opening the opportunity in CRM you want to generate a quote for.
*Make sure you have System Calculated selected in the Forecast Information section and select the relevant price list for the product you are quoting.  Save the opportunity.
Step 2: Select Line Items in the Information section and click inside the Line Items sub-grid.  A new tab titled List Tools will appear at the top.  Select Add New Opportunity Product and select the Write-In product option.
CRM 2011 Opportunity Product Screen
Step 3: Give your product a name in the Write-In product field and specify your product values in the Pricing field.  Save after this is completed.  The system will calculate your extended amount.  Save and close.
*Note that you can add multiple line items by repeating steps 2 and 3.  For example: you may    add services, annual enhancement plans, user license fees, etc.
Step 4: Select General from the Information section then select Recalculate Opportunity.  Your total will be calculated and displayed in the Est. Revenue field.  Save the opportunity then select Quotes in the Sales section.
Step 5: Select Add New Quote and a new quote form will be generated.  All of your line items will appear in the quote.  (Verify all of your products have been brought over by selecting Products under the Common section in the left navigation.) You are able to add costs you don’t want in your opportunity record to the quote by selecting Add Quote Product, then select Recalculate.
Step 6: Finally, select Run Report on the Data tab and select Quote.  The Report view will open and display your quote.  From here you can easily export the quote to many different formats including: XML, CSV, PDF, MHTML, Excel, TIFF, and Word.
CRM 2011 Final Quote Screen
Integrate your quotes, orders, and invoices with your back office in Microsoft Dynamics® GP or Microsoft Dynamics® AX.

Saturday, September 17, 2011

How to Hide a Dashboard in Microsoft Dynamics 2011

In Microsoft Dynamics CRM 2011 there are a number of predefined system dashboards:
image
In many cases, organizations/clients may or may not have need of some of these “out-of-the-box” dashboards.  They might, however, have need of them in the future.  So how do you remove them from a user’s view, but preserve them so you can bring them back in the future?  In my particular situation, the question came up, “How do you remove these, but not delete them?”  Great question.
There is not an out of the box way to “hide” a dashboard with the current Microsoft Dynamics CRM 2011 functionality.  But there are some options to preserve the original dashboards, while removing them for your users.
One way to do this is to export the dashboard to a solution file, then delete the original dashboard. In CRM 2011, create a solution in settings-->Solutions.  Click add existing dashboard, and select the dashboard that you want to remove.  Then export the solution and save the exported file in your source code repository of choice.  This file will contain a backup of the original system dashboard, and you can then delete the dashboard from your CRM 2011 system.  Should you ever change your mind down the road, you can restore the deleted system dashboard by importing the solution file.
Another option is to create a NEW Dashboard, based upon the existing dashboard.   This can be done by clicking on “Save As” from the Ribbon Menu Bar:
image
So for this example, let’s assume we like the Marketing Dashboard, but would rather hide it from users until a time when we want to use it.  By clicking "save as," I’ll create a personal dashboard, based upon the Marketing Dashboard.  The personal version will, by default, be only be visible by me:
image
In this case, I’ll just add “ORIGINAL” onto the end of the name of the dashboard, so that I’ll know the source.  Now that I have a my dashboard saved as a personal dashboard, which only I can see, I can now remove the dashboard that I do not want to be seen in my users’ Dashboard list.  This can be done through Customizations:
image
In this case, I checked the “Marketing Dashboard” on my list and clicked “Delete”.  You will get a Confirm Deletion dialogue box.  Click “OK” and the Dashboard is deleted.  To confirm this, we can go back to our Workplace –> Dashboards and see that it is no longer in our listing:
image
So now that you have a backup personal copy of the marketing dashboard, you can use it as a point of reference should you ever want to reconstruct the deleted dashboard as a system dashboard, or you can just share your personal dashboard copy with other users.  This is done by selecting the dashboard, “Marketing Dashboard – ORIGINAL” – and then clicking the “Share This Dashboard” button on the Menu Bar.  This will bring up the sharing dialogue box.  You can then share the Dashboard with an individual user or Team.
image
You can also rename the Dashboard in the customization-->dashboards area, if you would like to do so.
Good luck with your Microsoft Dynamics CRM 2011 implementations and configuration!

Tuesday, September 13, 2011

Disable All Fields in a Section Based on the Value of Another Field (CRM 2011)


There are SDK and web examples of how to disable or hide an entire tab on a form in Microsoft CRM 2011, but I was unable to find an example of how to just disable all the fields in a given section on the form based on the selection of a boolean option ("Two Option" field).
The scenario is useful if, for example, you want to disable data entry in the fields of a section under certain conditions, but you want to still display the disabled fields (rather than change their visibility and hide them). You could reference each field in the section by name and add the .setDisabled(true) method to the end of the control. But this is messy - what happens if later on the fields in the section are changed by adding new ones or removing others?
The script I came up with below handles this pretty nicely. All you need to know is the label of the section you're concerned with. In this example, I have a boolean field on another section (that's important - you don't want to disable this field and then the user can't change it back!).
//THIS FUNCTION DISABLES ALL THE FIELDS IN THE SECTION LABELED "FINANCIAL INFO"
//IF A BOOLEAN OPTION FIELD IN ANOTHER SECTION CALLED new_toggleSectionFlds = TRUE

function DisableSectionAttributes() {
    function setFldDisabled(ctrl) {
        ctrl.setDisabled(true);
    }
    function setFldEnabled(ctrl) {
        ctrl.setDisabled(false);
    }
    var toggleSectionFlds = Xrm.Page.getAttribute('new_toggleSectionFlds').getValue();
    var ctrlName = Xrm.Page.ui.controls.get();
    for (var i in ctrlName) {
        var ctrl = ctrlName[i];
        var ctrlSection = ctrl.getParent().getLabel();
        if (toggleSectionFlds == true) {
            if (ctrlSection == "Product Info") {
                setFldDisabled(ctrl);
            }
        }
        else {
            if (ctrlSection == "Product Info") {
                setFldEnabled(ctrl);
            }
        }
    }
}
Put this function in a web resource and then reference it from your form. Call the "DisableSectionAttributes" function in the OnLoad of your form, and in the OnChange of the new_toggleSectionFlds field. Notice that the section name "Product Info" is specified in both the "if" and the "else" part of the function - otherwise you would end up disabling all the other fields on the form!