Microsoft Dynamics CRM 2011

Microsoft Dynamics CRM 2011
Showing posts with label Advanced Search. Show all posts
Showing posts with label Advanced Search. Show all posts

Monday, September 16, 2013

How to create a Custom View using the Advanced Search in Dynamics CRM

by Carmel Schvartzman
  1. In this walkthrough we will learn Step-By-Step How to use the Advanced Search in Dynamics CRM 2011, and save the search as a Custom View. The Advanced Search allows to perform custom searchs of entity records,  export the results to Excel and even save the search as a View for further use.  For instance, we could use  the Advanced Search to find all the Accounts with a Name containing "Sean":

    How to create a Custom View using the Advanced Search in Dynamics CRM
  2. So go to Accounts and find the Advanced Search ribbon button:
  3. The Advanced Search dialog will open. Press the New button OR select "New" from the Views list:
  4. Because we want  to find all the Accounts with a Name containing "Sean", we need to select the "Account Name" field:
  5. Next add the operator "Contains":  (notice you can also select Equals, Begins , Contains Data, and more):

  6. Next, click over "Enter Text" and type the searched term "Sean":

  7. Click on "Results" to find out whether we got the expected results:

  8. We got them, but there is a column we don't need ("Primary Contact"), so let's remove it. Click on "Edit Columns":

  9. On the Edit Columns dialog, select the column to remove, and click "Remove":

  10. Now, if we need to retrieve data from another column, click on Add Columns:

  11. Select the column you need to add:

  12. Click "Results" again to see the required data:

  13. Now, we want to see how to save the Advanced Search as a View, for future use, so go to Save As:

  14. Give the View a relevant name and its Description:

  15. In the future, you can see the saved View opening the "Saved Views":

  16. There we'll see our Advanced Search saved as a View:






    That's all...Enjoy Dynamics CRM


    כתב: כרמל שוורצמן

Tuesday, September 10, 2013

How to use the Advanced Search in Dynamics CRM

by Carmel Schvartzman
  1. In this walkthrough we will learn Step-By-Step how to use the Advanced Search in order to retrieve entity records, related to a parent entity with a MANY-TO-ONE relationship.
  2. Let's say we created a N:1 relationship between Account to Campaign: a campaign applies to many accounts. We want to search accounts, some of its fields, and its related campaigns.
  3. Let's say we want to retrieve all the Accounts named "Sean":go to the Accounts workplace, and select "ADVANCED SEARCH":
  4. Select the NEW view:
  5. On the FIELDS combo, select the field Account Name:
  6. Select from the combo the CONTAINS option:
  7. Finally, our condition will be : "Account Name contains 'Sean'":
  8. Press RESULTS to see whether the query returns what we need:

    The results are correct. But let's say we don't need the "Primary contact" column, so we delete it:
  9. Select "Edit Columns" to remove the field:
  10. Select the column and click on "Remove":

  11. Now we want of course to add another column: we'll learn how to add a column that relates to another entity: click "Add Columns":

  12. This Campaign Name field holds the dependency N:1 between Account to Campaign. Add the column:

  13. Go to "Advanced Find" and press RESULTS again to see what we get:



    Besides the "Main Phone" field, we got the "CAmpaign Name", which is the related entity in the N:1 relationship. Clicking it will lead us to the corresponding Campaign for this Account

    That's all...
    Happy programming!!!!
כתב: כרמל שוורצמן

How to retrieve entities using FetchXml in Dynamics CRM

by Carmel Schvartzman

  1. In this walkthrough we will learn Step-By-Step How-to develop an application to programmatically RETRIEVE instances of an entity, using a FetchXml query expression, in Dynamics CRM.
  2. FetchXml is a query language used by Microsoft Dynamics CRM 2011, that can be serialized and saved for future uses. It also allows users to create custom reports. The FetchXml query can be used to instantiate a FetchExpression for use by the RetrieveMultiple() method of the IOrganizationService.
  3. There is no need to create an xml file or code: Microsoft Dynamics CRM 2011 can create automatically a FetchXml for us, while using the Advanced Search. Therefore, we'll use this method to create the query.
  4. First, we create a new console project an Visual Studio:
    How to retrieve entities using FetchXml in Dynamics CRM
  5. Add the following references to the project:
  6. At the Properties tab, change the target framework to .NET 4:
    retrieve entities using FetchXml in Dynamics CRM
  7. Next, write the standard CRM SDK code to instantiate the IOrganizationService:

  8. Now, turn to your CRM UI. Let's say we want to retrieve all the Accounts named "Sean":go to the Accounts workplace, and select "ADVANCED SEARCH":

  9. Select NEW view:
  10. On the FIELDS combo, select the field Account Name:
  11. Select the "Contains" option:
  12. Finally, our condition will be : "Account Name contains 'Sean'":
  13. Press RESULTS to see whether the query returns what we need:


    The results are correct. But let's say we don't need the "Primary contact" column, so we delete it:
  14. Select "Edit Columns" to remove the field:
  15. Select the column and click on "Remove":
  16. Now we want of course to add another column: we'll learn how to add a column that relates to another entity: click "Add Columns":
  17. This Campaign Name field holds the dependency N:1 between Account to Campaign. Add the column:
  18. Go to "Advanced Find" and press RESULTS again to see what we get:


    You can see we got a link that leads to the related entity Campaign. That's good.
  19. Now that we got what we wanted, let's download the query that did the search:
  20. Save the downloaded file and take a look to the xml: you'll recognize the search condition that we stated:
  21. Copy-paste the xml to a string in our project:
  22. Now replace the ( " ) with a ( ' ) :
  23. Next, instantiate a FetchExpression with the query string:

    How to retrieve entities using FetchXml in Dynamics CRM
  24. And finally, call the IOrganizationService method RetrieveMultiple(), using the expression:



    Now we get the required records into an EntityCollection, that we can loop with a foreach:



    This is about How to retrieve entities using FetchXml in Dynamics CRM.
  25. That's all..
    Happy programming!!!!

כתב: כרמל שוורצמן