Date post: | 26-Jan-2015 |
Category: |
Technology |
Upload: | kevin-dostalek |
View: | 25,302 times |
Download: | 1 times |
Top Twenty-Something InfoPath 2010 Tips & TricksSHAREPOINT SATURDAY, OZARKS 2012
PRESENTED BY: KEVIN DOSTALEK
Introductionswho‘s who
Agendawhat‘s what
Something for Everybodya tale of 3 cubes ORhow to follow along at home
Not that hard, until the last 30% or so
Easy (once you know a few tricks)
Awesomely flexible, but you can get into
trouble quickly
Typical InfoPath Solutions (Integrated)
Basic InfoPath Solutions (OOB)
Developer InfoPath Solutions (Code)
Display a [fake] message box on the web (IPFS)
No msgbox.Show() like methods
Normal Rule “Show value of field” not IPFS compatible
Build your own based on a view
• Centered table with data-bound text field and OK button
• Store the “message” in a field and set before switching views
• Use “dimmed” background for nice effect
For special purpose dialogs, create their own view1
Display a [fake] message box on the web (IPFS)
1
Display a [fake] message box on the web (IPFS)
1
Use Resource Files
Add resource from Data tab
Use resources in picture buttons (“picture” and “hover”)
• That way they are only stored once, even if you copy and paste them multiple times.
Use resources for secondary data source XML files (see also tip #19)
2
Use validation rules to allow variable validation checking (to support drafting)
3
Add an IsSubmitting Boolean field
Don’t use “Can’t Be Blank” field property
Create Validation rule that checks IsSubmitting property
Create a Tabbed Interface
Use either views or hidden sections for content
Use either styled command buttons or custom picture buttons for the tabs
4
Create a Tabbed Interface
Use formatting rules and “currentTab” field to control which tab is shown as active. If using hidden sections, then they are also controlled by formatting rules (based on currentTab value)
Use click action rules to set currentTab field. If using views, then this action will also change the current view.
4
Use SP library to dynamically swap images using rules and secondary data source
5
Secondary data source – SP List w/ Picture Column
Use picture object in form
Use rules to query
• filter by something unique, like ID or filename)
Create a link from anywhere to a form in IPFS
6
/_layouts/FormServer.aspx?XsnLocation=[URLtoXSN]&Source=[URLtoRedirectWhenDone]&DefaultItemOpen=1
/[PathToDocLib]/[PathToFile].xml
To open up a new form instance in a form library:
To open up an existing form instance in a form library, just set link to the InfoPath file (.xml)
Create a link from anywhere to a form in IPFS
To open up a new list item with customized form:
To open up an existing list item with customized form:
6
/_layouts/listform.aspx?PageType=8&ListId=[ListGUID]&RootFolder=
/_layouts/listform.aspx?PageType=6&ListId=[ListGUID]&ID=[ItemID]
Disable the backspace key in browser form (IPFS)
7
Create a copy of the FormServer.aspx layouts page, and inject some “anti-backspace” javascript code in the <head> section
Change your form links to your new aspx page
Use Excel Services REST interface to host business calculation logic
Allows business users / analysts to create and maintain business calculation logic in the tool they know best (Excel)
Create Excel Doc, add named ranges for parameters (inputs) and return values (outputs).
Publish to Excel Services in SharePoint
8
Use Excel Services REST interface to host business calculation logic
Add REST Webservice DataSource in InfoPath with an URL:
Create a rule of type “Change REST URL” and use a formula (concat) to put in the parameter values you want, then run “Execute Query” the data connection.
8
/_vti_bin/ExcelRest.aspx/Shared%20Documents/ratecalc.xlsx/Model/Ranges(‘BILLRATE')?$format=atom&Ranges(‘SALARY')=0&Ranges(‘GP')=0
Use Excel Services REST interface to host business calculation logic
Grab the return value in the secondary data source – find the named range, and grab the “fv” value from the cell
8
Use Excel Services REST interface to embed a dynamic chart
• Easy way to insert charts and graphs into InfoPath
• Construct a URL similar to the way outlined in the previous tip, but use “image” format, and /model/Charts(‘xxx’)
• Have a named chart/graph in Excel doc that is published to Excel Services in SharePoint.
• In InfoPath insert a Picture object/field (use “as a link”)
• In a rule, set the picture field value to the dynamic URL you created above (use formula to inject parameter values)
• Image will auto-refresh when the field value changes9
/_vti_bin/ExcelRest.aspx/Shared%20Documents/rest_demo.xlsx/Model/Charts(‘CHART1')?$format=picture&Ranges('PARAMETER1')=0&Ranges('PARAMETER2')=0
Basic cascading drop downs (single denormalized list)
• Put data in a single list with denormalized values, e.g. :
• Create secondary data source, query data when appropriate – this could be a list in SharePoint or XML
• Create you controls/fields, set them to “Get choices from an external data source”, bind the display name and valuefields to the appropriate fields in the secondary data source
• Check “Show only entries with unique display names”10
Country SubRegion Region
Angola Central Africa Africa
Cameroon Central Africa Africa
Djibouti Eastern Africa Africa
Fiji Melanesia Oceana
Basic cascading drop downs (single denormalized list)
Set filter conditions on each (except the top level) so that it only displays rows that match the parent field’s selected value (from the main data source)
10
Basic cascading drop downs (single denormalized list)
Set rule actions on each control (except the bottom level) so that when it’s value changes the downstream selection (previous choice) is cleared (set value = “”)
10
Parent/Child data from SharePoint lists
Set up each list with it’s own secondary data source
Set up drop down controls to be bound to the appropriate data source and set the display/value mappings
Create an action rule for the “parent” dropdown.
• Set the query field for the child data source to be the current (selected) value in the parent field
• Execute the query on the secondary data source
11
Fix Sandbox Code Deployment Issues for Large Forms/Code
If you get the error stating the form was deployed successfully but can only be opened in InfoPath Filler:
12
Ensure you have browser compatibility turned on
Address any errors the design checker shows
Check the ULS Log, filter on “InfoPath”, fix any code problems
Increase the WorkerProcessExecutionTimeout
• $spcode = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local$spcode.WorkerProcessExecutionTimeout = 45$spcode.Update()(then restart services on all servers where it is running)
Decrease complexity of the form
Split functionality into multiple forms
Use an XML file and rich-text controls to store re-usable tooltips
Create an XML file with your tooltips and save to SharePoint
Add XML file as a secondary data source in InfoPath
Drag field to form as RTB, then clean up formatting13
Create wizard interfaces when you have lots of conditional logic for data collection
Wizard interfaces are great when you need to control what information is displayed to a user in serial path logic. Use one of the following methods:
Hidden Sections
• Show sections based on a variable (“StepNum”) and change this variable based on the click action of a button (“Next”) combined with your conditional logic from other fields
Views
• Navigate to views based on click action of button (“Next”) combined with your conditional logic from other fields14
Query user data from the UserProfileDataWeb Service
• Add secondary data source (SOAP)
15
Query user data from the UserProfileDataWeb Service
Set the AccountName queryfield
Execute the Query
Filter by PropertyData:Name
Grab the ValueData:Value field
15
Moving data connections from one environment to another
Convert data connections to Data Connection Files
Move UDCX files into a Module Feature for deployment
Create a feature receiver to replace ListID GUID’s and Web URL’s
16
Using the XPATH translate function for case-insensitive comparing
String comparisons are case sensitive
Use translate formula to do case-insensitive comparisons
17
translate(/my:field1, “ABCDEFGHIJKLMNOPQRSTUVWYXZ”, “abcdefghijklmnopqrstuvwyxz”)
Use the XPATH Double-Eval trick to parse through a repeating section
eval(eval(group, “field”), “..”)
eval(eval(group, “concat(field, ‘; ‘)”, “..”)
18
Store variable values in secondary XML data source
Variable Values
• Only needed at run-time
• Do not need to be persisted across sessions
• Initialized on form load
Do not store these in the main data connection
• Increases form instance file storage size
• Increases form schema complexity
Create a secondary XML data source for these
• Add XML file as a resource (see tip #2)
• Remember to initialize values as needed19
How to track if your form has been changed or not (dirty-check)
Add secondary data source for variable usage (see tip #20)
Add a variable to this named “InitialState”
On FormLoad event, Set this variable to the root node of the main data source
When you need to do a dirty-check, compare the root node of the main data source to this field20
Debug Your Server-Side Sandbox Code
• Use VSTA to set debugging options• Project Menu – Properties – Build – Advanced – Debug Info
• Tools Menu – Options – Debugging – General – JIT Settings
• Build and publish form to server
• Use VS2005, load project, set breakpoints• Debug - Attach to SPUCWorkerProcess.exe21
Passing data into a form using a QueryString
Create a field mapping in your form and mark it as an web part connectable parameter
On your page add an InfoPath form viewer web part and a querystring filter webpart. Configure both.
Connect the filter web part to the InfoPath webpart using the field that you defined above.
22
Use an SPD workflow and an impersonation step to move form to a secured library
23
Setting a dynamic submit location in code
24
Centralize your Form XPATHs
25SetFieldValue(FormXpaths.ApplicantUsername, "test\admin", false);
Build your XML Helper Library
26
Fix IPFS Scroll Behavior when changing to a new view
• Problem is that browser will retain scroll position when doing a server side post-back, even if the view changes so that scroll-position is no longer in context
• Not just a problem for InfoPath views. Happens elsewhere in SharePoint (like paging through a list)
• I have no solution, but have done much investigation
• Root cause is in core.js javascript
• Could be fixed by injecting some javascript to counter the auto-scroll behavior (see tip #7)
• Tricky part is deciding when you should scroll and when not to scroll… this behavior is defaulted this way for a reason!
• I’d love to work with some of you on this!27
Thanks to Our Sponsors!
Platinum
Housekeeping
Follow SharePoint Saturday Ozarks on Twitter @SPSOzarkshashtag #SPSOzarks
Stop by and thank our sponsors for making this event possible!
Fill out and turn in evaluation forms to be eligible for the end-of-day raffle. You must be present to win.
Don’t miss “This Modern Station” tonight at Waxy O’Shea’s!
Thank You!
Please find me:
• (to learn) BLOG: http://thekickboard.com
• (to hire me) COMPANY: http://kickstudios.com
• (to stalk) TWITTER: http://twitter.com/thekicker
• (to spam) EMAIL: [email protected]
• (to hang) LOUNGE: [email protected]
Please be sure you:
• Create some super awesome InfoPath solutions
• Use InfoPath responsibly (think maintainability!)