Everybody loves to use InfoPath forms. And let’s face it, we all wish we could just take them and put them into CRM. What I’ve written is a simple way to do that without the hassle of figuring out how to bind the InfoPath form schema to a custom WCF service. It still doesn’t do everything I want it to, but it works, so I figured I’d go ahead and put it out there for everyone to look at, play with, and even use.
If you are interested in this solution, you can download the following:
- Managed Solution (this is the only thing you need)
- Unmanaged Solution (in case you want to modify mine, like add grid support, it is on my to-do list)
- Source Code (this is in case you would prefer to use a WCF service or if you just want to play around with my code)
Once you’ve installed the managed solution, you’ll need to do the following to create / setup an InfoPath form:
For this particular InfoPath integration, you need to create InfoPath Forms that mirror a CRM Entity.
Note: You can always create a new entity for the form data.
Rename the default form Group to the name of the entity (ex: Contact)
Inside CRM create the InfoPath form (it is an entity included in the solution), select the entity and save the form.
Once it has been saved, you can copy the ID using the “Copy ID” link in the header.
Note: If you do not select the Allow Any CRM Field checkbox, you will need to add the individual Fields, which can be found in the left navigation.
In the InfoPath Form Designer, add a field named SubmissionCode with the Default Value as the ID you just copied.
Note: Using the submission code allows us to check and see if the form is valid, active, and allowed.
Add a field for each of the fields in CRM that you want to be available, selecting the appropriate data type.
Note: Unfortunately I have not had the time to test the fields and have been using the checkbox on the infopath form record to enable any/all CRM fields. However, I did not want to delay releasing the code and information as it currently is. If someone identifies a problem with this or any other section of the code, I’ll be happy to look into it and work on resolving the issue.
Layout the fields on the form, then click File > Submit Options > To Email
Enter the Queue email or where you want new forms to be submitted.
- Save and close the form designer.
Open the form and test submission.
Once the email comes into CRM, the process of reading the form is easy; you just open it up and click the Import InfoPath button on the ribbon.
Usually I would post the source-code and comment on how it works in great detail, but this time, it really depends on which component. There is a plugin and WCF service written in C# as well as two Jscript files, one for the buttons and one for the InfoPath form inside CRM that creates a drop-down of the entities in CRM. I would suggest downloading the unmanaged solution and source-code if you want to delve into those items.
Now, for complex situations or form conversions, binding the InfoPath schema is the way to go. Using that method (the one described in detail on Philo’s Weblog) you can import the InfoPath form schema into Visual Studio:
- Create an InfoPath form and lay it out the way you want it.
- Extract the form files (File | Extract Form Files) to a location you can find later.
- Close the InfoPath form designer.
- Open the Visual Studio command prompt.
- Change to the directory where you extracted the files
- Run xsd against the myschema.xsd in that directory, and specify the namespace you would like to use.
Note: My WCF namespace is CrmInfoPathService and my plugin namespace is InfoPathPlugin.
xsd.exe myschema.xsd /classes /l:cs /n:InfoPathPlugin
- Then you can deserialize the xml into the object and store it in CRM or any other system using the logic embedded in your code.
The key point to my solution was not to do something that everyone does on occasion, but to make something so that I can leverage it in the future and not have to create a new integration every time I wanted to leverage a new form. Now, on that note, here are the list of things that if you delve into, I’d like to know, a.k.a. my to-do list for this project:
- Add a button onto the grid for activities
- Create a way to handle child entities.
- Modify the plugin/WCF code to link the created entities to the form email using connections.
- Change the button on the form to monitor for the results (success/failure) and report back to the user.
- Any great ideas my readers think should be added!