Top 20 something info path 2010 tips and trips - sps-ozarks12


Published on

Published in: Technology

Top 20 something info path 2010 tips and trips - sps-ozarks12

  1. 1. Top Twenty-SomethingInfoPath 2010 Tips & TricksSHAREPOINT SATURDAY, OZARKS 2012PRESENTED BY: KEVIN DOSTALEK
  2. 2. Introductionswho‘s who
  3. 3. Agendawhat‘s what
  4. 4. Typical InfoPath Solutions (Integrated) Not that hard, until the last 30% or soSomething forEverybody Basic InfoPath Solutions (OOB)a tale of 3 cubes ORhow to follow along at home Easy (once you know a few tricks) Developer InfoPath Solutions (Code) Awesomely flexible, but you can get into trouble quickly
  5. 5. No msgbox.Show() like methodsDisplay a [fake]message box on Normal Rule “Show value of field” not IPFSthe web (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 1 For special purpose dialogs, create their own view
  6. 6. Display a [fake]message box onthe web (IPFS) 1
  7. 7. Display a [fake]message box onthe web (IPFS) 1
  8. 8. Add resource from Data tabUse Resource Use resources in picture buttonsFiles (“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
  9. 9. Use validationrules to allow Add an IsSubmittingvariable validation Boolean fieldchecking (tosupport drafting) Don’t use “Can’t Be Blank” field property Create Validation rule 3 that checks IsSubmitting property
  10. 10. Use either views or hidden sections for content Use either styled command buttons or custom picture buttons for the tabsCreate a TabbedInterface 4
  11. 11. 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)Create a Tabbed Use click action rules to set currentTab field. If using views, thenInterface this action will also change the current view. 4
  12. 12. Use SP library todynamically swap Secondary data source – SP List w/images using rules Picture Columnand secondarydata source Use picture object in form Use rules to query 5 • filter by something unique, like ID or filename)
  13. 13. To open up a new form instance in a form library:Create a linkfrom anywhere /_layouts/FormServer.aspx?XsnLocationto a form in IPFS =[URLtoXSN]&Source=[URLtoRedirectW henDone]&DefaultItemOpen=1 To open up an existing form instance in a form library, just set link to the InfoPath file (.xml) 6 /[PathToDocLib]/[PathToFile].xml
  14. 14. Create a link To open up a new list item with customized form:from anywhereto a form in IPFS /_layouts/listform.aspx?PageType=8& ListId=[ListGUID]&RootFolder= To open up an existing list item with customized form: 6 /_layouts/listform.aspx?PageType=6& ListId=[ListGUID]&ID=[ItemID]
  15. 15. Disable the Create a copy of the FormServer.aspx layouts page, and injectbackspace key in some “anti-backspace” javascript code in the <head> sectionbrowser form(IPFS) 7 Change your form links to your new aspx page
  16. 16. Allows business users / analysts to create and maintain business calculation logic in the tool they know best (Excel)Use Excel ServicesREST interface to Create Excel Doc, add named ranges for parameters (inputs) and return values (outputs).host businesscalculation logic Publish to Excel Services in SharePoint 8
  17. 17. Use Excel Services Add REST Webservice DataSource in InfoPath with an URL:REST interface to /_vti_bin/ExcelRest.aspx/Shared%20Documents/ratecalc.xlsx/host business Model/Ranges(‘BILLRATE)?$format=atom&Ranges(‘SALARY)=0calculation logic &Ranges(‘GP)=0 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
  18. 18. Grab the return value in the secondary data source – findUse Excel Services the named range, and grab the “fv” value from the cellREST interface tohost businesscalculation logic 8
  19. 19. • Easy way to insert charts and graphs into InfoPathUse Excel Services • Construct a URL similar to the way outlined in the previous tip, but use “image” format, and /model/Charts(‘xxx’)REST interface toembed a dynamic /_vti_bin/ExcelRest.aspx/Shared%20Documents/rest_demo .xlsx/Model/Charts(‘CHART1)?$format=picture&chart Ranges(PARAMETER1)=0&Ranges(PARAMETER2)=0 • 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 9 created above (use formula to inject parameter values) • Image will auto-refresh when the field value changes
  20. 20. • Put data in a single list with denormalized values, e.g. : Country SubRegion Region Angola Central Africa AfricaBasic cascading Cameroon Djibouti Central Africa Eastern Africa Africa Africadrop downs (single Fiji Melanesia Oceanadenormalized list) • 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 value fields to the appropriate fields in the 10 secondary data source • Check “Show only entries with unique display names”
  21. 21. 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)Basic cascadingdrop downs (singledenormalized list) 10
  22. 22. 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 = “”)Basic cascadingdrop downs (singledenormalized list) 10
  23. 23. Set up each list with it’s own secondary data sourceParent/Child Set up drop down controls to be bound to the appropriatedata from data source and set the display/value mappingsSharePoint lists 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
  24. 24. If you get the error stating the form was deployed successfullyFix Sandbox Code but can only be opened in InfoPath Filler:Deployment Issues Ensure you have browser compatibility turned onfor LargeForms/Code 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() 12 (then restart services on all servers where it is running) Decrease complexity of the form Split functionality into multiple forms
  25. 25. Create an XML file with your tooltips and save to SharePointUse an XML fileand rich-textcontrols to storere-usable tooltips Add XML file as a secondary data source in InfoPath 13 Drag field to form as RTB, then clean up formatting
  26. 26. Create wizard Wizard interfaces are great when you need tointerfaces when control what information is displayed to a user inyou have lots of serial path logic. Use one of the followingconditional logic methods:for data collection 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 14 Views • Navigate to views based on click action of button (“Next”) combined with your conditional logic from other fields
  27. 27. • Add secondary data source (SOAP)Query user datafrom theUserProfileDataWeb Service 15
  28. 28. Set the AccountName queryfieldQuery user datafrom the Execute the QueryUserProfileData Filter by PropertyData:NameWeb Service Grab the ValueData:Value field 15
  29. 29. Convert data connections to Data Connection FilesMoving data Move UDCX files into a Module Feature for deploymentconnections fromone environment Create a feature receiver to replace ListID GUID’s and Web URL’sto another 16
  30. 30. String comparisons are case sensitiveUsing the XPATHtranslate function Use translate formula to do case-insensitive comparisonsfor case-insensitivecomparing translate(/my:field1, “ABCDEFGHIJKLMNOPQRSTUVWYXZ”, “abcdefghijklmnopqrstuvwyxz”) 17
  31. 31. Use the XPATH eval(eval(group, “field”), “..”)Double-Eval trickto parse through arepeating section eval(eval(group, “concat(field, ‘; ‘)”, “..”) 18
  32. 32. Store variable Variable Valuesvalues in • Only needed at run-timesecondary XML • Do not need to be persisted across sessionsdata source • 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 19 • Add XML file as a resource (see tip #2) • Remember to initialize values as needed
  33. 33. How to track ifyour form has Add secondary data source for variable usage (see tip #20)been changed ornot (dirty-check) Add a variable to this named “InitialState” On FormLoad event, Set this variable to the root node of the main data source 20 When you need to do a dirty-check, compare the root node of the main data source to this field
  34. 34. • Use VSTA to set debugging options • Project Menu – Properties – Build – Advanced – Debug InfoDebug YourServer-SideSandbox Code • Tools Menu – Options – Debugging – General – JIT Settings 21 • Build and publish form to server • Use VS2005, load project, set breakpoints • Debug - Attach to SPUCWorkerProcess.exe
  35. 35. Create a field mapping in your form and mark it as an web part connectable parameterPassing data intoa form using a On your page add an InfoPath form viewer web part and a querystring filter webpart. Configure both.QueryString Connect the filter web part to the InfoPath webpart using the field that you defined above. 22
  36. 36. Use an SPDworkflow and animpersonationstep to move formto a securedlibrary 23
  37. 37. Setting adynamic submitlocation in code 24
  38. 38. Centralize yourForm XPATHs SetFieldValue(FormXpaths.ApplicantUsername, 25 "testadmin", false);
  39. 39. Build your XMLHelper Library 26
  40. 40. • Problem is that browser will retain scroll position whenFix IPFS Scroll doing a server side post-back, even if the view changes so that scroll-position is no longer in contextBehavior when • Not just a problem for InfoPath views. Happens elsewherechanging to a in SharePoint (like paging through a list)new view • 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! 27 • I’d love to work with some of you on this!
  41. 41. Thanks to OurSponsors! Platinum
  42. 42. Follow SharePoint Saturday Ozarks on Twitter @SPSOzarks hashtag #SPSOzarks Stop by and thank ourHousekeeping 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!
  43. 43. Please find me: • (to learn) BLOG: http://thekickboard.comThank You! • (to hire me) COMPANY: • (to stalk) TWITTER: • (to spam) EMAIL: • (to hang) LOUNGE: Please be sure you: • Create some super awesome InfoPath solutions • Use InfoPath responsibly (think maintainability!)