When you need to create a map pulling data from a CRM query data source, and you want to limit the data pulled based on criteria. To do this, you need to create a global variable and set that value in a Map Pre Task. The first thing you need to do, is create a new global variable. I created GBL_STATE to be used as criteria for State column in CRM.

051016 1422 TechTuesday1

In your map pulling CRM data, create a task that runs before the map, this will set the new global variable to the state of MN. You could also add code to prompt the user to enter the criteria if needed, and set the global variable at run time. Another option in the map pre task, do a query to pull the data from another source such as a SQL table.

051016 1422 TechTuesday2

In the source, setup the source as CRM Query and set your organization. Click the modify button and chose your entity and columns needed. In the field you need to apply the criteria, the State/Province in this example, enter the criteria = GBL_STATE and move off that line to save the criteria

051016 1422 TechTuesday3

 

If you click the Data tab to verify this is working, you will get an error message similar to this:

051016 1422 TechTuesday4

The reason, the global variable has no default value when we created it, and cannot find a record with a blank state criteria.

To resolve this, you need to set the Default value in the Global variable setup shown in step 1 in this document. You can also set the default value just for this map. Click on the Global Variables tab within the SmartConnect Map, enter a default value, move off the line and click save.

051016 1422 TechTuesday5

Save the map and reopen the map. This will save the default value and be used to preview the data. Now when you click preview it will show you only the records where the start = MN. If you have added criteria to prompt the user for the criteria at the time you run the map, you will not be able to run that map on a scheduled basis.

051016 1422 TechTuesday6