Monday, December 8, 2008

Check if combination of values is already entered, using Repeating Controls

Several posts explains how to use drop down list boxes in repeating tables, assuring that the users can only select values which are not selected in previous rows.  This article describes how to extend this validation, to assure the combination of several fields are not entered in previous rows.

Solution:

1. Within the repeating node, add ahidden TextBox, called UniqueValue
2. Set the Default Value to Concat(field1, field2,..)    Field 1, Field 2,... are the fields that will make the row unique
3. Add the following rule to the newly created field:
       Condition: The Expression
      
Expression: ../my:UniqueValue = (../preceding-
       sibing::my:Group2 | ../following-
       sibling::my:Group2)/my:UniqueValue)

    Action:
Show Dialog box with some message that the
     combination of fields already exists


Group2: is the name of the repeating node within the data-source

Tips: Remove Administrator Approval when publishing the InfoPath form to SharePoint

Sometimes, when publishing an InfoPath form to SharePoint, the Publishing Wizard tell you that the form must be approved by an administrator.


This is a normal behavior when your form contains code, but what if you are sure your form doesn't contain custom code.

To clean up the link, go to
  • - Menu Tool -> Form Options
  • - Select Programming
  • - Click on the Remove Code button in the Programming
  •   Language Section

    this action will remove the link to the Code Project.  Once this link is available in the Form, even without code you wrote, the Administrator Approval is required.