Qdabra's Zero-ActiveX Contact Selector XTP - Mel Balsamo
in

InfoPath Dev

This Blog

Syndication

Mel Balsamo

Qdabra's Zero-ActiveX Contact Selector XTP

PROBLEM

You want to use the InfoPath Contact Selector to add multiple contacts to your form, but:

  • Selecting multiple users with Contact Selector requires code
  • Contact Selector is an ActiveX control and requires installation on client machines
  • Contact Selector doesn’t work for browser-based forms when the user is not using Internet Explorer

SOLUTION

Install Qdabra’s Zero-ActiveX Contact Selector

  • Based on Qdabra’s qRules library – extend your InfoPath forms without writing code
  • Easy-to-add XML Template Part – just add custom control via the InfoPath 2007 Designer
  • Comes with pre-configured layout which saves you time – just drag and drop from the taskpane
  • No ActiveX – works with browser based forms

QUICK PREVIEW

Let’s take a quick look: here is a screenshot of Qdabra’s Zero-ActiveX Contact Selector XTP

 

In the screenshot, the user searched for all users with “admin” in their Active Directory records and then clicked on the arrows to add Jim Cantwell and Patrick Halstead to the form.

This blog post details the steps needed before you begin using the XTP in your InfoPath forms; just a few modifications and tweaks and you’re ready to go!

REQUIREMENTS

  • QdContactSelectorXTP – Contact Selector template part, no ActiveX required, no code.
  • InfoPath 2007 – template parts (XTPs) are not supported in InfoPath 2003.
  • Qdabra Database Accelerator – includes the Active Directory Web Service. Download a FREE trial here. Alternatively, you may purchase Qdabra’s Active Directory Standalone tool here.
  • Qdabra qRules  – add the most commonly requested InfoPath features without the need of writing code. Download a FREE trial here.
  • Admin-deploy to SharePoint – qRules is a library that contains code, so when you publish your form to SharePoint you need to publish it as an administrator approved form. This requirement goes away for SharePoint 2010.

ADD THE TEMPLATE PART IN INFOPATH CUSTOM CONTROLS

1. Launch InfoPath and select Design a Form Template based on a new blank one.

2. In the Controls taskpane, click Add or Remove Custom Controls…

 

3. In the Custom Controls dialog box, click Add > Template Part, and browse to the location where you placed your QdContactSelector XTP.

 

4. Verify that the XTP has been added to your Custom Controls taskpane.

 

5. Save your form template (XSN). For the purposes of this blog post, we will name it as ContactSelectorXSN.

6. Close InfoPath.

INJECT QRULES AND THE XTP

1. Launch the qRules Injector from Start > All Programs > Qdabra > Tools > qRules Injector.

 

2. Browse to the location where you saved your ContactSelectorXSN.

3. Click Inject, then OK in the confirmation dialog, and then close the qRules Injector.

4. Open ContactSelectorXSN in InfoPath Design mode.

5. Scroll down to the very bottom of the Controls taskpane to get to the Custom section, and then click on the QdContactSelector control.

You should now have the template part on your canvas. The main and the secondary data sources will be injected in your XSN as well.

 

SOURCE FILES CLEAN-UP

If you go to Tools > Data Connections, you will notice that you have two instances of QdabraRules, one for the XSN, and one for the XTP:

 

When you first injected qRules in your XSN, it added the QdabraRules XML as a secondary data source. In this same XSN, you injected the QdContactSelector XTP which also uses qRules. This added another QdabraRules XML secondary data source to the XSN (with a different name). So now, you have two qRules XMLs, which is confusing and might cause issues when calling the qRules commands, hence the need to do some clean-up.

1. Save ContactSelectorXSN as source files and close InfoPath.

2. Modify the manifest.xsf file:

a. In the directory where you saved your source files, locate manifest.xsf and open it in any text editor.

b. Replace all seven instances of “QdabraRules_QdContactSelector” with “QdabraRules”.

c. Delete the associated blocks where you find “QdabraRules1”:

i. xsf:file (for .xsd)

 

ii. xsf:file (for .xml)

 

iii. xsf:dataObject

 

d. Save and close manifest.xsf.

3. Modify the sampledata.xml file

a. Open sampledata.xml in a text editor.

b. Delete the xd:DataConnection block where you find “QdabraRules_QdContactSelector”.

 

c. Save and close sampledata.xml.

4. Delete the extraneous QdabraRules1 files in the source files directory:

a. QdabraRules1.xml

b. QdabraRules1.xsd

5. Verify changes.

a. Open manifest.xsf in InfoPath Design mode.

b. Go to Tools > Data Connections and verify that you now have only one instance of QdabraRules.

 

MODIFY THE ACTIVE DIRECTORY DATA CONNECTION

1. In Tools > Data Connections, modify the FindUsersByName_QdContactSelector data connection.

2. Replace servername (in http://servername/qdabrawebservice/ADUserInfo.asmx?WSDL) with the correct location where you installed DBXL.

 

Note: If you are using Qdabra’s AD Standalone Tool, the AD Web Service URL should be in the format: http://servername/QdabraAD/ADUserInfo.asmx?WSDL.

3. Click Next and make sure that the FindUsersByName operation is selected. Click Next again.

4. Leave the tns:name parameter blank, and for the tns:searchType*, select Contains.

 

5. Click Next twice more, then Finish to exit out of the wizard.

MODIFY THE QRULES COMMANDS

Since you’ve added the QdContactSelector XTP into an XSN, you need to make sure that the qRules commands point to the new fields’ XPaths.

1. Double-click on the  button to open its properties.

 

2. Click Rules and modify all the three actions in the Insert User rule:

 

a. Change the first action that calls the Insert command to:

Insert /parent=/my:myFields/my:UserList /child=/my:Alias /count=1

 

b. Change the second action that calls the SetValue command to:

concat("SetValue /xpath=/my:myFields/my:UserList/my:Alias[last()] /value=", @value)

 

Note: @value refers to a field in the form. If in doubt, tick the checkbox labeled Edit XPath to see the full xpath of the @value node.

c. Do the same for the third action for the SetValue command:

concat("SetValue /xpath=/my:myFields/my:UserList/my:Alias[last()]/@my:name /value=", @display)

 

3. Click OK as many times needed to close all the dialog boxes.

4. Double-click on the  button to open its properties and modify the Remove User rule.

 

In the Insert Formula dialog, check on the Edit XPath (advanced) box and change the Delete command to:

concat("Delete /xpath=/my:myFields/my:UserList/my:Alias[", count(preceding-sibling::my:Alias) + 1, "]")

 

5. Click OK until all dialog boxes are closed.

6. Add conditional formatting so that, when users have already selected a contact, they can no longer add the same contact.

a. Double-click on the  button to open its properties.

b. Go to the Display tab > Conditional Formatting > Add.

c. Add a condition such that if Alias (from the main data source):

 

is equal to the value node (from the FindUsersByName_QdContactSelector secondary data source):

 

then hide the control:

 

d. Click OK until all the dialog boxes are closed.

e. Do the same for the @display field. Double-click on the textbox to open its properties.

 

f. Go to the Display tab > Conditional Formatting > Add.

g. Add a condition such that if Alias (from the main data source) is equal to the value node (from the FindUsersByName_QdContactSelector secondary data source), then change the font color to something lighter:

 

h. Click OK until all the dialog boxes are closed.

That’s it! You’re all set to use Qdabra’s Zero-ActiveX Contact Selector! Test your XSN in Preview mode and search for users, select contacts and even delete them. Finish designing your form template, save it, and you’re ready to go!

PUBLISH TO SHAREPOINT

Here’s a link to an article describing how to publish your new form to SharePoint so you can use it in the browser.

You can also refer to the User Guide that comes with your qRules v2.0 installation for instructions on how to use your qRules solutions in InfoPath Forms Services.

Comments

 

Ernesto Machado said:

During Qdabra’s free weekly webinar on November 10, 2011, we discussed three possible contact selectors

January 25, 2012 10:53 AM
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.