There are not many things that Integration Manager does as well or better than SmartConnect but there is one small little feature that is pretty nice that SmartConnect doesn’t have out of the box. That feature is the ability to quit processing additional records if a certain error threshold has been met. We can add this feature fairly easily with a simple task and a Global Variable. The following instructions should help you when you are testing or having something inherently wrong with a setup and they are not just for GP, this can be for Dynamics CRM, Salesforce.com, Dynamics NAV, Xero, Concur, Zendesk, Files, SQL, etc.

1) We need to create a Global Variable to set the Maximum Number of Errors. Go to the Maintenance-Global Variables area inside of SmartConnect

global0

2) Now, add a new Global variable with the name GBL_ERROR_MAX and set the default value to 10 (or whatever threshold you desire).

global1

This will now be the default value that can be used accross all maps but you also have the ability to change that on each map by selecting the Global Variables section of each map and overriding with a map specific value like below:

global2

3) Now we need to add a new task under the Tasks section. This task will be on the Pre-Document area and the type will be a Script task.

task1

4) Copy the following script into the task:

if Convert.ToInt32(GlobalErrorCount) >= GBL_ERROR_MAX then
     ‘If you want to show a message when the maximum number of errors has been
     ‘reached before stopping the map processing, uncomment the line below:
     ‘MessageBox.Show(“The Map processing was cancelled after ” & GlobalErrorCount & ” errors.”)
     return false
else
     return true
end if

Make sure that the On Fail section has been changed to Cancel processing. If you would like to have a message pop up telling you that the map has stopped processing because it has reached your maximum number of errors then you can uncomment the ‘MessageBox.Show line and change any wording that you want.

It should look like this when you are done:

task2

5) Run the Map! It will now show that is has stopped processing after reaching the maximum amount of errors. In the example below I have set the max errors to 2 and also enable the Message telling me that is has quit because of reaching the max amount of errors that was set.

runmap

I think you will see how useful and easy to implement on each map going forward. The really nice thing is that you are not limited to Dynamics GP maps with the functionality. It can be used accross the spectrum of our destinations from File, SQL, CRM system and Web Services.

Thanks,
Chris