The Image field type has been available since CRM 2013 to allow users to display pictures within records in certain entities. This provides a more intuitive way to present records in CRM application. Recently, we have received many emails from our clients asking about how to upload record image during the integration process, so we have decided to write this blog to share our solution.
In this blog, we would like to demonstrate how easy it is to work with the Image field (entityimage) by using our SSIS Productivity Pack and SSIS Integration Toolkit for CRM. Before we start to talk about our solution, let’s take a look at the entityimage field first.
What is entityimage field?
Entityimage is an Image type field that stores image information for records. This field is available for certain system entities and some of them are enabled by default. For custom entities, you would also be able to create this field by yourself and display the image in your CRM application. Please note that in this case, only one image field is allowed per entity.
Below is the list of supported system entities, those marked with an asterisk are enabled by default to show entityimage in CRM (credit from MSDN):
Account * |
KbArticle |
Campaign |
Incident |
Competitor * |
Connection |
Contact * |
Contract |
TransactionCurrency |
EmailServerProfile |
Goal |
Invoice |
Lead * |
Mailbox |
OpportunityProduct |
SalesOrder |
Organization |
Product * |
Publisher * |
Queue |
Resource * |
SalesLiterature |
Territory |
SystemUser * |
Our next question is how to work with this field. In order to update the entityimage field, you will need to supply the binary value of the file content. A widely used component during this step will be the Import Column component.
- Import Column component: An SSIS out-of-box transformation component that can be used to read data from files and add the data to the data flow buffer. It is capable to perform the job but the inconvenient configuration is always painful for our integration development.
Solution for Updating Entityimage Field
In this section, we will give an example and show you how to use a single function in our Premium Derived Column component to upload images to contact entity as a much easier alternative to the out-of-box functionality in SSIS.
As the screenshot shown above, our data flow task is quite straightforward, which includes three components:
- Flat File component: An out-of-box source component which allows you to read data from your local file system.
- Premium Derived Column component: A more advanced Derived Column component that offers nearly 200 functionalities and with more to come. In this example, we are going to use one of them, ReadBinaryContent(), under the File I/O Functions catalog.
- CRM Destination component: One of the featured components that we offered in our SSIS Integration Toolkit for CRM, which has many desirable options to work with Dynamics CRM.
Updating Entityimage Field - Example
1. Prepare the upload list
As you can see from the screenshot below, we are going to upload three images to the corresponding contact records. In this example, we will use a flat file to store the mapping list and supply the contact name as the unique identifier for update action. Please note that it is possible to use either text value or GUID value as the primary key as we offer a Text Lookup feature in our CRM Destination component.
2. Convert the file content
As we have mentioned, the entityimage field only accepts binary content, so in this step we are going to use the ReadBinaryContent() function to read the image stored in the file system and get the appropriate data to pass to CRM application. This function takes the file path as the input parameter and returns the binary content of the file into the output Column. We simply drag and drop the function to the Expression column.
3. Build the mapping
The last step is to build the mapping of related fields and specify the Update action in the CRM Destination component.
- Map the contactName field to the contactid field;
- Map the imageContent field to the entityimage field
Notice that we have setup a text lookup on the contactid field as we are passing the name value to this field. You can find more information on how to use the Text Lookup feature here.
Final Results
The image uploading process becomes relatively straightforward with our Premium Derived Column component. Comparing to the Import Column component, we offer:
- Friendly user interface with simple drag and drop experience;
- Build-in function that you could utilize right away.
There are also more easy-to-use and high-performance SSIS components in the SSIS Productivity Pack for you to discover and you will realize how this premium pack could help you achieve your integration goal in a more productive way.
Sample SSIS Package
A sample SSIS package is available for download here. The sample package was prepared in a SQL Server 2008 R2 format, and it should automatically upgrade if you are using any newer version of SSIS.