March 2009 - Posts - Mel Balsamo

InfoPath Dev

This Blog


Mel Balsamo

March 2009 - Posts

  • Active Directory Template Part

    The Active Directory Web Service is a very powerful tool for retrieving user information in our solutions, making them easier to fill out. What’s even more convenient is the ability to just inject it into our forms in a single mouse-click – and there’s the Active Directory template part.


    This blog post details the steps on how to create a template part (XTP) that calls the Active Directory Web Service and retrieves the currently logged in user’s information, as well as the manager’s. Follow along and use the template part as many times as you wish!


     This template part tutorial uses Qdabra’s Active Directory Web Service that comes with DBXL. To download a free DBXL trial, click here.


    1)      Open InfoPath and design a new blank template part.

    2)      Add the following groups and fields to your main data source:

    3)      Design your XTP as shown below:

    4)      Add secondary data connections:

    a.       Go to Tools > Data Connections > Add.

    b.      Create a new connection to receive data from a Web service.

    c.       Enter the URL: http://<servername>/QdabraWebService/ADUserInfo.asmx where <servername> is the location where DBXL is installed.

    (Note: If you are using the Active Directory Standalone Tool, the URL should be http://<servername>/QdabraAD/ADUserInfo.asmx)

    d.      From the list of operations, select GetMyInfo.

    e.      Check the box that says “Automatically retrieve data when the form is opened”, then click Finish.

    f.        Repeat Steps 4a to 4d to add data connections for the GetUserInfo and GetManagerAlias methods.

    ·         You can leave the parameters blank as we will specify each of them later as we continue designing our form.

    ·         For the rest of the methods, uncheck the box that says “Automatically retrieve data when the form is opened”.

    g.       When done, exit the data connections wizard.


    5)      Configure the EmployeeInfo fields:

    a.       Double-click on the EmployeeName field to display its properties.

    b.      In the Data tab, click on the fx button to set a default value.

    c.       In the Insert Formula window, click the Insert Field or Group button.

    d.      Select the secondary data source GetMyInfo from the data source drop-down.

    e.      Expand the dataFields node to display Value, and click Filter Data.

    f.        Add a filter so that it only displays data when Key is equal to the text displayName.

    g.       Click OK until all the dialogs are closed.

    h.      Repeat Steps 5a to 5g for the EmployeeEmail field, except that Value should be filtered such that Key is equal to the text mail.

    Hint: To view a list of all the Active Directory keys, drag the whole ADProp node (/dfs:myFields/dfs:dataFields/tns:GetMyInfoResponse/tns:GetMyInfoResult/tns:ADProp) as a repeating table onto your form, and then preview.


    6)      In the Controls task pane, click to add a button between the Employee Info and the Manager Info table.

    7)      Double-click on the button to display its properties.

    8)      Label the button as Get Manager Info, and click Rules > Add > Add Action.

    9)      Add the following actions to query your manager’s alias using your alias which we obtained through GetMyInfo:

    a.       Set the field /dfs:myFields/dfs:queryFields/tns:GetManagerAlias/tns:username to the value of /dfs:myFields/dfs:dataFields/tns:GetMyInfoResponse/tns:GetMyInfoResult/tns:ADProp/tns:Value filtered such that Key is equal to sAMAccountName.

    b.      Query using the GetManagerAlias data connection.

    c.       Set the field /dfs:myFields/dfs:queryFields/tns:GetUserInfo/tns:username to the value of  /dfs:myFields/dfs:dataFields/tns:GetManagerAliasResponse/tns:GetManagerAliasResult

    d.      Query using the GetUserInfo data connection.

    e.      Set the ManagerName field /my:myFields/my:ManagerInfo/my:ManagerName to the value of /dfs:myFields/dfs:dataFields/tns:GetUserInfoResponse/tns:GetUserInfoResult/tns:ADProp/tns:Value filtered such that Key is equal to displayName.

    f.        Set the ManagerEmail field to the value of /dfs:myFields/dfs:dataFields/tns:GetUserInfoResponse/tns:GetUserInfoResult/tns:ADProp/tns:Value filtered such that Key is equal to mail.


    Your button rules should be similar to this:


    10)   Still in the button properties window, go to the Display tab > Conditional Formatting > Add.

    11)   Add the following conditions to disable the button if the Employee Info fields are blank:

    12)   Click OK to close all the dialogs.

    13)   Preview your template part. The Employee Information table will auto populate with your Active Directory Information. Clicking the Get Manager Info button retrieves your manager’s info as well.

    14)   Save your template part.



    For you to be able to use it in your forms, you must first install the template part in InfoPath. Here are the steps to do that: 


      1. In InfoPath Design mode, click Controls in the task pane, and scroll down to the Custom section found at the very bottom of the task pane.
      2. If you haven’t installed any custom controls (like template parts), you will see that the Custom section is empty. Click Add or Remove Custom Controls, and then click Add in the dialog box that appears.
      3. In the Add Custom Control Wizard, select Template Part from the options and click Next.
      4. Browse to the path of your template part, and click Finish then Close when done.
      5. The template part will now show in the list of your installed template parts. Click OK to close the dialog box.
      6. After successful installation, the template part will now be available in the Custom section of the Controls task pane.

    To use it in your form, just click the template part and it will be shown on InfoPath’s design area. You can then continue designing your form and edit the sections in the template part as necessary.


    Additional Info:

    If you have added a template part to InfoPath as a custom control, modifying the template part will not change the control. You have to uninstall the current version from your custom controls in InfoPath (using Add or Remove Custom Controls) and then add your new version.


    In a real working environment, you must send the updated template part to anyone who is using the original. After the updated template part is installed on each computer, the users are notified that an update is available, thus the need to update the existing forms that are using the template part.


    *** The Active Directory template part is included in the Active Directory Standalone Tool. Click here to purchase the tool. ***


  • Smart Links - Speed up Contact Lookups!

    In a previous blog post, we’ve shown you a template part called Contact Block Advanced, and described how useful it is for keeping a record of contact persons / employees for every company, all in one place. One of its cool features is the ability to speed up contact lookups by using Smart Links. This blog post shows you how to create a sample form that uses Smart Links. Start by following the steps below and see how amazing and convenient it is to use Smart Links in your solutions.


    1.       Design a blank InfoPath form template.

    2.       Add the following nodes to your main data source: 



    3.       Add tables and controls to your form similar to this:



    4.       Add default values to the Address1 attributes:

    a.       In the Data source task pane, double-click on the GoogleMaps attribute and specify a default value:


    concat("", .., ", ", ../../my:Address2, ", ", ../../my:City, ", ", ../../my:State, " ", ../../my:Zip, " ")


    Click on Verify Formula to check that you have entered the correct one. Your formula should be similar to this:



    b.      Double-click on the LiveSearch attribute and specify a default value:


    concat("", .., ", ", ../../my:Address2, ", ", ../../my:City, ", ", ../../my:State, " ", ../../my:Zip, " ")



    c.       Do the same for the MapQuest attribute:


    concat("", .., ", ", ../../my:Address2, "&city=", ../../my:City, "&state=", ../../my:State, "&zipcode=", ../../my:Zip)



    5.       Add hyperlinks to Address1 that link to its attributes:


    a.       Add a space after the Address1 label, right-click and select Hyperlink:



    b.       For the Link to, select Data source and enter my:Address/my:Address1/@my:GoogleMaps. Enter GoogleMaps in the Text field under Display.




    c.       Do the same for LiveSearch and MapQuest:

    LiveSearch – my:Address/my:Address1/@my:LiveSearch

    MapQuest – my:Address/my:Address1/@my:MapQuest


    d.      You can add open and closed parentheses, as well as separators for the hyperlinks so they’d look neater:



    6.       Do the same for all the other remaining attributes, specifying the following default values and pointing each hyperlink to its corresponding data source:


    a.       Phone (@call to) - concat("callto://+1", ..)

    b.      Email (@mail to) - concat("mailto://", ..)

    c.       Website (@url) - concat(substring("http://", 10 * number(contains(.., "://"))), ..)


    Your form should be similar to this:



    Test your form in Preview mode by filling out the fields and clicking each corresponding Smart Link:


    Address (LiveSearch):




    Phone (Skype Call):




    Email (Send Mail):



    Website (Visit Website):




    Smart Links are the best way to go to look up data in your forms. It is mostly useful in solutions that contain contact information. You can even create template parts that use Smart Links, and use them in your forms right away.


    NOTE: The Smart Links used in this blog post are applicable only in the United States.

  • Electronic Signature Template Part

    Would you like to add signatures to your form, but are concerned about the challenges of setting up digital certificates? Qdabra’s Electronic Signature Template Part may be right for you! Here’s a sneak peak:

    Note: The PIN field is highlighted as shown in the figure above, but it normally wouldn’t be seen since the texts are colored white.


    User enters invalid information:

    User enters valid information:

    What is it? What does it do?

    -          Electronic signatures don’t require digital certificates


    -          Electronic signatures ask for a personal identification key, for example a PIN


    -          Electronic signatures use your logged-in user credentials to look up a previously recorded key in the Signature library


    Ø  If the entered data matches the key data stored in the Signature library, the electronic signature adds a signature image to your form.


    -          Electronic signatures can include a purpose field for auditing

    -          Electronic signatures template part is designed in a way that it's plug-and-play, so you can easily use them in your forms

          InfoPath 2007 introduces XML Template Parts (XTPs),  which let you take whole sections of a form – fields, rules, data connections, conditional UI, etc. – and package them up so you can reuse them in all of your forms.


    What will I need to use the Electronic Signature Template Part in my InfoPath form?


    -          InfoPath 2007 or later –Template parts (XTPs) are not supported in InfoPath 2003


    -          SharePoint 2007 or SharePoint 2010 lists - securely store PINS and signature images

    -          Scanned in signatures and users' aliases – to create above list


    Why do I need SharePoint?


    SharePoint feature alert! One of the best things to note about using SharePoint is that there is no need to create a form to store the signature. Your users can store their signature in a picture library and secure each signature image so that users cannot access other users’ signatures and PINs. And the best part is – no code needed!


    Why not a secondary XML resource?


    Good idea! We could add a secondary XML file in the InfoPath template that stores the employee alias, PIN and signature image (as Base64), but here again, we have two issues:


    a)      Security – we’d have to encrypt the PIN so that users couldn’t steal it by cracking open the cached template file. Encryption requires code and that won’t work for XTPs.


    b)      Updating the XML file would be costly. Every time a new employee joins, you have to update the file.

    Granted, the security issue is only a big deal if you have malicious users and you could make it a little harder by hiding the Design This Form button in the toolbar. Fair enough! If you don’t have SharePoint, and want us to blog the non-secure secondary XML file send us e-mail and complain loudly. If we hear from enough of you, we’ll post another blog using the XML file technique.


    If you don’t have SharePoint, you can still read about the technique to learn about how to use XTPs.


    Why not digital signatures? What limitations do electronic signatures have?


    Security warning: An electronic signature doesn’t prevent a malicious user from downloading and modifying the XML data after signing. That’s what Digital Signatures are for – they include special checks that prevent data tampering. The problem with Digital Signatures is that they require digital certificates and that means you have to have your system admin turn on Certificate Authority, or purchase certificates from a Web provider. Electronic signatures are a semi-secure substitute and with SharePoint permissions, you can prevent most tampering using the following three techniques:


    a)      Don’t store employee’s PINs in the main data source. Even though you need the field in the XTP, you can blank the field out after you replace it with the signature image (assuming the user entered a valid PIN)


    b)   Remove the Save and Save As options from the InfoPath File menu (Form Options -> Open and Save)


    c)   An administrator secures each signature image so that users cannot access other users’ signatures and PINs. A good way to do this is to have an admin upload “dummy” signatures and PINs and then place security on each one.  The users can then go in and modify the signature image and PIN, replacing them with their own.


    d)   Digital Signatures require domain users but Electronic Signatures do not.

    Are you ready to create the solution?


    Create your Picture Library

    1.      Create a SharePoint Picture library in a location accessible to all employees needing an electronic signature by going to Site Actions > View All Site Content > Create and choose Picture Library.


    2.      Give your picture library a name such as ElectronicSignatures, and choose whether or not you want to add it to the Quick Launch bar and create versions. Click Create.


    Note: Since we’re using a separate library for the PIN storage, make the picture library read only for all users. Each signature should be editable by whomever it belongs to. The issue is that currently, the signature is populated by a link. If the link is not reachable by other users, the signature will not show in the form. So the URLs of the picture library need to have read access. Signature is then created from pulling the pin from one list and the document from another.


    3.      Upload “dummy” or false signatures using the following guidelines:


    a.      Signatures should all be of the same type (.jpg, .gif, .tiff, etc.)


    b.      Signatures should be given the name that the user has for his/her Network ID (machine name). For example, if the network recognizes John Smith as SHAREPOINT\JSmith, his signature should be named “JSmith”.

    In some cases, the document’s Name field is not available to users, so we can make use of the Description field too. Enter the same name (user’s network ID) in the Description field.


    c.       Signature image “Title” should be the user’s full name.


    d.      Signatures should all be uploaded to the same library.


    4.      Once all the dummy signatures are uploaded, have an administrator go in and secure each of the signatures.

    a.      Select a signature picture by clicking on it. The picture will display as an enlarged thumbnail with a toolbar across the top.


    b.      From the toolbar, select Manage Permissions.


    c.       Currently, each picture inherits its permissions from the library it resides in, so first we need to break inheritance. Click Actions > Edit Permissions. You will receive a warning that you are breaking inheritance.

    d.       Click OK to continue.


    e.      Your permission list will now have check boxes next to all the users.

    f.        Ensure that the owner of the electronic signature is listed as one of the users in this list.


    If they are not, select New > Add Users. Choose the owner of the signature by typing their username or using the browse function of the Add Users text box. Select the permission level you want them to have (Contribute is the safest option. This will allow them to manage their signature without being able to change the permissions on it.) Click OK.


    g.      Once the user is added to the permissions list, place a check in the boxes next to all the other names, and click Actions > Remove User Permissions. You will be asked if you are sure you want to do this. Click OK. The other users will be removed from the list and the only remaining user should be the owner of the signature.


    h.      You may test this by signing in with a dummy account or having another user who does not have access to the signature sign in with their account. They should not see the protected signature.


    i.        Now that your signatures are protected, have your users go in and change the dummy signature image to be their real signature that is in .jpg format. They can just give their signature the same name, that is their useralias, and upload it – it will overwrite the dummy signature.

    Note: Please configure permissions so that users can upload their own signature image but that others cannot view them. You’ll also want to make sure that only one signature exists for each user.


    Create a list to hold the PINs

    1.      Create a Sharepoint Custom List by clicking View All Site Content > Create, and choose Custom List.


    2.      Give your custom list a name such as PIN List and choose whether or not you want to add it to the Quick Launch bar. Click Create.


    3.      Add a column for a PIN by clicking Settings > Create Column.


    4.      For each user, create an item specifying the user’s alias as the Title, and leave PIN blank.

    Figure 7

    5.      Secure each PIN access by only the user who owns the PIN (follow the same procedures as above for protecting the signature images).


          6.   Have your users enter their individual PINs.

    Get the ID (GUID) from SharePoint

    Before we edit the data connections, you have to get the ID (GUID) of your SharePoint library and list. To do this, follow the steps below:

    1.   Navigate to your Picture library using the browser.

    2.   Click Settings > Picture Library Settings.

    3.   Click on Audience targeting settings.

    4.   Copy the GUID from the browser address bar. You will need to copy everything after the equal (=) sign.


    5.   Paste the GUID in a text editor of your choice. You’ll need them later when editing the data connections.   

    6.   Repeat the same steps for your PIN List library.NOTE: If you don’t have the link “Audience targeting settings” in your SharePoint library/list settings, follow the steps in this blog to decode the GUID.

    Edit the UDC Files

    Electronic Signature UDCX

    1.   Open ElectronicSignatures.udcx that is included in the template part package in any text editor of your choice.

    2.   Find the udc:SelectCommand node and replace the ListId with the GUID of your Electronic Signature picture library.

    3.   Replace the WebUrl with the root URL of your SharePoint site.

    4.   Save changes to ElectronicSignatures.udcx.

    PIN List UDCX

    1.   Open PINList.udcx that is included in the template part package in any text editor of your choice.

    2.   Find the udc:SelectCommand node and replace the ListId with the GUID of your PIN List.

    3.   Replace the WebUrl with the root URL of your SharePoint site.

    4.   Save changes to PINList.udcx.

    Upload the Data Connection Files to SharePoint

    1.   If you haven’t done so, create a data connection library by going to Site Actions > View All Site Content > Create and choose Data Connection Library.

    2.   Give your data connection library a name such as MyDataConnections, and choose whether or not you want to add it to the Quick Launch bar and create versions. Click Create.

    3.   Click Upload and browse to ElectronicSignatures.udcx, make sure that it’s the file you’ve previously edited. Click OK.

    4.   SharePoint will confirm once the data connection file is successfully uploaded. There is no need to make changes in the next window. Click OK.

    5.   Repeat steps 3-4 to upload PINList.udcx.

    Approve the UDCX Files

    1.   In your data connection library, click the down arrow for ElectronicSignature.udcx and select Approve/ Reject.

    2.   Select Approved button and click OK.

    3.   Repeat steps 1-2 to approve PINList.udcx.

    NOTE: The data connection files must be accessible to all users. To make sure all users have access, select the UDCX file and click Manage Permissions. Use the permission tools to grant access to all users or ensure that the active directory group that should have access to the files is added in the list.

    Modify the Template Part

    1.   Open the Electronic Signature template part (qESxtp) in InfoPath Designer.

    2.   Save as source files.

    a. InfoPath 2007: Click File > Save As Source Files…
    b. InfoPath 2010: Click File > Publish > Export Source Files

    Edit the Data Connections

    1.   Now go to the folder where you saved the source files.

    2.   Find manifest.xsf, right click to it and open in Notepad.

    3.   Find the node called <xsf2:dataConnections>.

    4.   Edit the source link of the data connection for PIN List. Make sure that the source value is correct. If you have created the data connection library in the root site, <DataConnectionLibrary>/PINList.udcx should be used. But, if you have your data connection library in a subsite, you should use <subsite>/<DataConnectionLibrary>/PINList.udcx.

    5.   Edit the site collection for PIN List. Make sure to put the link to your SharePoint root site with a forward slash at the end of the link.

    6.   Edit the source link of the data connection for Electronic Signature. Same as the PIN List, make sure that the source value is correct. If you have created the data connection library in the root site, <DataConnectionLibrary>/ElectronicSignatures.udcx should be used. But, if you have your data connection library in a subsite, you should use <subsite>/<DataConnectionLibrary>/ElectronicSignatures.udcx.

    7.   Edit the site collection for Electronic Signature. Make sure to put the link to your SharePoint  root site with a forward slash at the end of the link.

    8.   Save the changes to manifest.xsf.

    Edit the Template Part

    1.   Go back to the folder where you saved the source files.

    2.   Open manifest.xsf in InfoPath Design mode.

    3.   In the Main Data source, expand the group called UserInfo and double-click on the LibraryURL field.

    4.   The value for this field is the link to the Electronic Signature library. Change the link to your Electronic Signature library. Don’t forget the slash (/) at the end of the link (e.g. http://<SharePointServer>/<subsite>/ElectronicSignatures/). Once finished, click OK.

    5.   Save As to your local directory, and name the new template part to Qdabra Electronic Signatures.


    Add the Template Part to your form

    1.   Open the form where you want to add the Electronic Signature template part.

    2.   At the bottom of the Controls task pane, click Add or Remove Custom Controls.


    3.   Click Add.


    4.   Select Template Part, click Next.


    5.   Browse to the location of the new Qdabra Electronic Signature template part and select the XTP.


    6.   Click Finish and Close. Click OK.


    7.   Put the cursor in the view where you want to place the Electronic Signature control.


    8.   Under Custom Controls, click on the template part to add it to the view.


    Test the form

    1.   Click Preview. When asked to connect to data sources, click Yes.

    2.   Enter your PIN and click Sign this document check box.
    3.  Your signature should be displayed.

    You can now publish your form to SharePoint and see how cool it is to use electronic signatures!


    One Caveat for those of you that want to use this with InfoPath 2007 browser enabled forms: InfoPath 2007 browser forms do not support picture controls (InfoPath 2010 forms do). So, instead of using both the signature picture and the DisplaySignedBy field, you will only be able to use the DisplaySignedBy field. In most cases, this workaround is just fine, since it takes up less room on the page and fits the same purpose.


    For your convenience, we are providing the Electronic Signature template part for sale via our Web store. Benefits:

    • Comes with a User Guide that contains in-depth instructions on how to add the rules for validation
    • Saves you time spent creating the XML Template Part. We’ve done it for you.
    • Includes PIN field and rules to check it.
    • Plug-and-play. Just customize the UDC connection and you're ready to go.          

    Purchase the Electronic Signature template part here.

Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.