Tuesday, June 26, 2007

Infopath Trips and Tricks

Phone Number (Format ): 1. Add a rule to your textbox control with the following conditions (make sure to select "and" operator): a. field "does not match pattern" Phone number b. the expression: string-length(translate(., "()- ", "")) = 10 c. the expression: string-length(translate(., "()- 0123456789", "")) = 0 2. Add action to the rule: a. Set a field's value b. Select your textbox field c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()- ", ""), 1, 3), ") ", substring(translate(., "()- ", ""), 4, 3), "-", substring(translate(., "()- ", ""), 7, 4)) Email Address Data Validation ( Infopath ) Email Address doesnot match pattern: ( custom pattern ) ([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?) ScreenTip & Validation message: Please Enter a Valid Email ID : abc@xxxx.com Date Validation : Enter a Date where past date doesn’t exceed 5 weeks There is the addDays() function in Infopath 2007. To use this in data validation, right click on the field you wish to validate, select Data Validation and select Add to open a new condition. Leave the first box set to your field, set the second box to is less than or equal to, and in the third box, select Use a formula. In the formula editor, insert the function addDays. The first argument should be your date field and the second should be -35 (to subtract 5 weeks): addDays(today(), -35) Add your screen tip as appropriate. If you want your date between a range, you can add a second condition. Should not be able to Enter a Future Date : Field less than or equal to today(), Retrieving values into expression box based on People picker control: (Like Email & Phone Here..) Limit amount of repeating table rows that can be created ( For Ex: SampleXSN Form make it 18) Steps: (1) Save your form ( SampleXSN) as source files. (2) Open the schema with a text editor (if you created it yourself, starting with a blank form in IP, it will be named myschema.xsd) and find the element bound to your repeating table. (3) You'll see the 'maxOccurs' is set to unbounded. Change that to 18 ( here ). (4) Save the file myschema.xsd. (5) Open the manifest or form file and publish it. (6) With this approach if they try to exceed the limit ( say 18 here ) End User will get a message “New item could not be inserted. In this Form only a max of 18 items allowed.” Users will still be able to add and delete rows in repeating table till they try to reach the limit set ( 18 here ). Note: After you saved as source files, close the Form if the Form is still open, it will be using the Form files like the schema and the schema which you open will be read only. Auto Numbering Repeating Section : (Ex: repeating section 1, repeating section 2…..) Use the function : count(preceding-sibling::*/ResolvedYes) + 1 ProblemOccurenceDetail is the Repeating Section: ResolvedYes is a section inside the repeating section. Where ResolvedYes is any field/group in the Repeating Section. Field16 is a test field on which we add the Logic Dynamically controlling the number of rows in a Repeating Table: Tip: Use the Count function. Count = Count(RepeatingTable) Under Conditional Formatting in a RepeatingTable If Count >= Condition(Dynamically set ) then Don’t allow the Users to add or delete rows. A value in the form may be used to specify the file name. If you know the value in the form that specifies the file name, revise it and try again. Otherwise, contact the author of the form template You need to make the changes in the share point submit data connection. The following steps will walk you through 1. Open form in Design Form 2. Go to Tools in menu bar 3. Select data connection 4. Select the Dta connection name that you had used to submit the form to Share Point 5. Click on 'Modify' button 6. Check 'Allow overwrites if file exists' check box 7. click on 'Next' button 8. Click on 'Finish' button 9. Click on 'Close' button 10. Save the form and republish the form to Your form Library Validating a group of checkboxes If the fields for your checkboxes Booleans? If so, you can set them so they have a value of 0 if cleared and 1 if checked. You can add another field and set its default value to the sum of the fields associated with your checkboxes (you don't have to connect it to your control or show it on your form anywhere). Then, for each of your checkboxes, your data validation condition can be if the field with the sum of the values is equal to zero, show an error..... Multiple DataConnection Submits ( EmailSubmit, DC Submit ) : Form has been closed. On the Button(Rules) (1) Switch to Email Submit View & Submit Email (2) Also submit to Form Library (3) Switch to View which you are initially on ( This is the View where your button is ) (4) Close the Form : No Prompt & It Works... What happens is it might be losing the link to URL to what you are supposed to go when you switch to Email View. When you change views back to original view you are on...It regains its URL and closes the Form with redirect URL. Also, Form has been closed error also occurs if any data-connection query fetch results in error : Ex: cannot find List.