Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.
Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.

InfoPath

VIDEO – PowerShell PNP to parse InfoPath XML Attachments

Wanted to share quick tutorial on how to parse InfoPath attachment XML.    Source Form Library contains XML with Base64 encoded attachments which we can parse into local TEMP folder and then upload to destination Document Library. Extract filename and file content for each InfoPath attachment XML node.  Save into subfolders and match original file naming.  Helpful for Office 365 migration and scenarios where InfoPath client is no longer available and users prefer to view attachments directly.

Video, screenshots, and source code below. 

Cheers

shades_smile

GitHub Repo

Video

Screenshots

SNAGHTML46f8607
image
image
image
image

InfoPath – search replace URLs within XSN

Need to migrate forms to another URL?   But not sure how to update many data connections?  Try the script below.

This PowerShell will extract XSN contents to a folder, execute string search replace, and “package” back into CAB format with XSN extension.   A simple way to migrate InfoPath forms to another DNS name for scenarios like AAM Alternate Access Mapping redirection and SharePoint major version upgrade (2007 > 2010 > 2013).

Enjoy! 

shades_smile

 

NOTE – Requires CABARC.EXE  http://stackoverflow.com/questions/3361928/where-can-i-get-the-cabarc-utility

 

InfoPath_UpdateDataConnetions.ps1

# Update InfoPath form URLs by extracting CAB and performing search replace
Param(
	[string]$xsnFile
)
Write-Host "Prepare folders..."
md c:\InfoPath\before
md c:\InfoPath\temp
md c:\InfoPath\after
Write-Host "Clean temp..."
Remove-ChildItem c:\InfoPath\temp\*.* -Recurse
Write-Host "Extract XSN... $xsnFile"
cabarc x "c:\InfoPath\before\$xsnFile" *.* c:\InfoPath\temp\
Write-Host "Replace URL..."
$txt = Get-Content c:\InfoPath\temp\Manifest.xsf
$txt |% {$_ -replace "//sharepoint/" "//sharepnt07/"} | Out-File -FilePath "c:\InfoPath\temp\Manifest.xsf" -Encoding UTF8 -Force
Write-Host "package XSN..."
cabarc n "c:\InfoPath\after\$xsnFile" c:\InfoPath\temp\*.*
Write-Host "DONE"

 

BreezeJS – Edit SQL table with < 100 lines of JS code [VIDEO]

With SharePoint 2013 and industry movement towards the cloud I’ve been exploring JavaScript as a primary way to develop rich applications.

One common challenge is data access.  

With C# I have years of experience with [System.Data] and can perform CRUD against SQL relational databases in my sleep.  Open connection, query, data adapter, fill DataTable, and voila!    Muscle memory. Second nature.  Tried and true methods.   However, in the new client side JS world I had no clue where to begin.

Enter Breeze.

 

People describe Breeze as “Entity Framework on the client in JavaScript” which sounds simple yet has profound implication for the developer.   CRUD operations, LINQ style query, navigating primary/foreign keys, input validation, caching, batch updates, and more.   That’s a lot to consider and new ideas take time to absorb.   Breeze could potentially replace:

  • ASP.Net (ASPX) web forms
  • ASCX user controls
  • InfoPath forms
  • SharePoint web parts
  • WCF 5.6 data services
  • OData
  • Classic WebAPI

 

I set out to code an example with a few goals:

  • Create simple SQL schema (two tables – parent/child – one to many)
  • Execute CRUD operations in JS against SQL  tables
  • Leverage JS plugins and NuGet “Install-Package” to load third party components
    • Install-Package breeze.webapi2.ef6
    • Install-Package breeze.angular
    • Install-Package angularjs.core
  • Little code as possible

The whole thing took less than 30 minutes and I edited video down to just 15.    I was impressed by how straightforward and easy the process was.   Breeze# in ASP.Net MVC for the back end WebAPI controller was nearly identical to the Breeze example code.   Add one C# method per entity (SQL table) and Breeze does the rest.  The JS front end took a little more time to understand but was also easy to apply.   Connect  Entity Manager to the Breeze URL and you’re ready for CRUD queries.    Amazing!     Given how easy Breeze is I would be hard pressed to use OData or manually created WebAPI controllers with C# code to query a database.   If you can use Breeze, then use it!    You’ll save lots of effort.

Please leave a comment if you found this helpful.   Thank you! 

shades_smile

 

Watch Video

[BreezeJS and WebAPI – Edit SQL table in JS with less than 100 lines of code]

 

Download Code

Download

http://spjeff.com/etc/Appraisal-Breeze-VS2013.zip

 

Screenshots

image
image

 

image

 

References

 

InfoPath tip – detect Security Group with List Item permissions

Yes, everyone says InfoPath is dead … but we’re all still supporting it for a while so I wanted to share one of my favorite tips.  Forms often need role based security at the field level.  Table below with example security matrix.

How can InfoPath detect that?   Don’t some people query SOAP ASMX?   Or even a custom WSP with a custom ASMX?   There is a simpler way with List Item permission.  

image
  1. Create a new Custom List named “SecurityLevel” with only the default “Title” column.  
  2. Go create the needed SharePoint Groups under Site Permissions.  
  3. Back in “SecurityLevel” add one new item for each SharePoint Group with an identical name.   Hover that item, pull down the menu, and set Item Level Permissions for that group ONLY to have “Read” on that item only.  
  4. With InfoPath Designer edit the XSN Form Template and create a new Data Connection to the list “SecurityLevel” with auto refresh.  
  5. Under Form Load create a rule … if count(SecurityLevel [“Analyst”]) > 0 then set field “SecurityLevel=Analyst”.   
  6. With that in place you are ready to apply formatting rules anywhere needed that use “SecurityLevel” to determine hide/show or read/write.

 

Voila!

Now when a user open the InfoPath form, the data connection “SecurityLevel” will only show the items they have access to (which is the same as the SharePoint Group membership!).    Works on MOSS 2007, SharePoint 2010, SharePoint 2013, and Office 365.

Hope this helps.  Please leave a comment if it did. 

shades_smile

 

DOWNLOAD  InfoPath Form – SecurityLevel.xsn >>

 

 

image
image
image
image
image

 

image
image
image

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲