In order to activate a feature via the client side we simply have to know the GUID of the feature.
If this is a site scoped feature this is pretty straight forward.
The following can be run from a script editor webpart;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
We can then use the GUID found with the next function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Infopath forms in SharePoint have some weird css styles when inspected.
There area number of ways to include css (see this link: Add-a-Custom-Style-Sheet-to-a-View.aspx) but they are limited by the weird, and what appears to be, computed class names.An example
This is really frustrating when trying to target specific elements, nobody wants to write css with that!!
I find embedded form web parts to be the best way to include Infopath forms in Sharepoint and they allow some external manipulation – such as query string integration and filtering – and also enable easier styling on the rendered objects via a script editor webpart.
An interesting problem raised its head – making InfoPath forms ready for mobile & tablet and finger friendly – the multi choice selection boxes have very little in way of styling that you can access, just padding, font size, borders… The lines are too close together and the checkboxes are too small.
Sadly these boxes don’t have a nice targetable name, they are part of a fieldset in a stupidly named div, so we can’t easily specify what to manipulate and just chuck in some css. We also want to change all the checkboxes throughout the form not just one field.
We can however use attribute selectors in CSS = [attribute$=value]
Easiest way to read ULS log error with Correlation ID
Simply run this in Powershell and replace the GUID with the one presented
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
A recent project required a detailed site structure and a set of terms for those sites to use for labeling data. The client had well established metadata and provided a taxonomy hierarchy. They wanted each site to have its set of terms to use in its document library for labelling its data. Our challenge was to script the creation of a site structure based upon this data in the Term Store and then provide these sites with the appropriate term set.
To clarify – each site needed to have a document library with a managed metadata field that uses a particular term set – all based upon the same site template so having an identical structure – the only difference being the site name and the term set to be used by the MM field in its document library.
Our first step was to create a CSV file to import the terms into the term store in the correct format – we chose a groupname “Functions” and loaded it in via the term store management tool with the following structure.
TermSetName – This will be referenced in the code – consider this the parent term
TermSetDescription – optional
LCID- optional
AvailableForTagging – optional
TermDescription – Optional
Level1 – This are the main terms – obviously cannot be blank – these will be the names of the site
Level2 – These are the terms that will be available to the sites by way of a managed metadata field
Level3, etc… – Your hierarchy will determine how complete this has to be, ours went down a few levels.
Next we created a site template to be used to provision all the sites. The structure was to be very simple with one document library with a managed metadata field pointing the parent term set.
To save a site as a template be sure to have the site feature “SharePoint Server Publishing” deactivated.
If you do not see the link to save the site as a template open the site in SP designer and select site options from the main page –
Now that we have the terms and the template we can write some powershell code…
The following code connects to the taxonomy service session and reads the term sets in the term store and writes an array with those terms
#Get the Term Store ID $TaxSession = Get-SPTaxonomySession -Site $SiteCollection $TermStore = $TaxSession.TermStores[“Managed Metadata Service”] #Change to your service name $TermStore.Id #Get the Term Set $TermStoreGroup = $TermStore.Groups[“Functions”] #Change to your Terms Store sets parent term (TermSetName) $TermSetList = $TermStoreGroup.TermSets #create an array $myArray = $TermSetList.Terms
Now we want to create a site structure to mimic this structure.
The next bit of code creates a site for each term (if it doesn’t exist already)
foreach ($element in $myArray) { write-host $element.name -ForegroundColor Magenta #writes the term $NewSiteUrl = $web + “/” + $element.name write-host $NewSiteUrl -ForegroundColor green #writes the new sites url #check if it already exists $exists = Get-SPWeb -Identity $NewSiteUrl -ErrorAction SilentlyContinue | Select-Object -Property Exists -ErrorAction SilentlyContinue if($exists -eq $null) { #create the new site $newweb = New-SPWeb -Url $NewSiteUrl -Name $element.name -AddToTopNav -UseParentTopNav #apply your template $newweb.ApplyWebTemplate($template.Name) write-host “Created” -ForegroundColor green } }
The next challenge was s to now make each site use the relevant terms in its document library managed metadata field.
To do this we need to cycle through each site, find its doc library and its Managed Metadata field and at the same time cycle through the terms in level 1 – we then set the anchor point of the field to the correct term set so that the child terms appear as choices in the document library.
So for our Human Resources site the Field should set like so…
By Exploring the schema of the managed metdata field you can determine the AnchorId
We need to update this AnchorID value to be the term guid as follows
$field.AnchorId = $element.id $field.Update()
See the full code below for how to find the field and the relevant term GUID
Script to Read Term Store and Create Sites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Script to update Managed Metadata Columns AnchorID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Came across something I saved a while ago from a Quora response to the question…
What are the some of the most interesting UI elements of recent times?
The majority of these suggestions that I have included were provided by Stephen P Anderson
You can read the rest of the answers here, lots of them refer to styling and I wanted to focus on interactions mostly.
I didn’t compile this list, I have removed a few but I’ll try to state my view on how as as SharePoint dev they might be well utilised, especially given the freedom the app model affords us.
“Sticky” headers/sidebar content – critical elements stay fixed as you scroll down the page (the way the GMail header stays fixed as you scroll through an email, lots of “share” functionality on blogs/magazines stays with you as you scroll down the page). See also http://fab.com/inspiration/ main nav. The text formatting options in Quora and Basecamp Next stay with you as you write longer posts.
Responsive layouts. ‘Nuff said about this! (well device channels aren’t gonna cut it – stick RWD in your branding)
Direct manipulation of objects (vs toggling between CRUD states). See how minutes.io puts you directly into the meetings page.
Web fonts – especially more humanistic/geometric typefaces like Proxima Nova, Museo Sans, and (soon) Gotham. See http://www.fastcompany.com/
More “discoverable” controls (for better “cleaner interface” or worse “how do I do x…!?”); the Metro UI from Microsoft is able to produce cleaner screens because secondary elements are “hidden” in corners and edges (see:http://msdn.microsoft.com/en-us/… ) We’re all used to this in the ribbon so embrace this technique)
Drop down options loaded with information and even pictures (modern drop downs often aren’t based on an actual UI drop down controls). we’ve all come across mega dropdown menus for navigation but including controls or extra content in your app can mean a much better UX flow
Bigger type sizes, hit areas, buttons and white space – so that Web apps might also be touch friendly w/o a lot of refactoring – we all know this is going to be useful
Options that resemble “cards” (think Pinterest.com and all the clones) – I can see this being a great technique for showing search result content, much richer for certain uses than a standard results list. We are now seeing this for people search and it’s a welcome development.
A move away from noticable gradients and drop shadows (still used, just in a much subtler way)
“Fake” drop shadows or borders – the ultralight 5 pix shadow that doesn’t “fade” away (Google apps do this a lot).
“As you need it” functionality – instead of functionality being exposed by default, it’s presented in a series of sequenced moments (clicking on “add a comment” link or box turns into expanded box with more options, OR rating something exposes a comment field – contextual and reactive based upon a users actions
Direct manipulation of default data, vs wizards to set things up
Auto save functionality (vs big “Save” button)
More drawers and slideouts from the top, bottom and edges. Similar to mega drop down menus but some different directions!
Inline expanding areas for additional information/actions – the SP “grouped by” list views are a good example, gives the users a broader view and the option to expand to see detail.
Very, very subtle textures, to draw light contrast that guides the eye through a page. See http://subtlepatterns.com/ as a resource for these. See Pinterest, Basecamp Next, and Branch.com as examples of sites with this subtle background that draws your focus to the content (focus area)
Search boxes that “expand” (width) on click – great idea
“Kiosk style” buttons – rather than present 4 radio buttons options, sites opt for the more visual display of text in rounded corner boxes (which actually aids in spatial recall and creates a bigger hit target) – currently revamping an InfoPath form to reflect this,
Conversational UIs – rather than a form label and drop down, you see a phrase with the drop down options worked into that phrase. For an extreme example of this (and the “kiosk style” buttons mentioned above). The enterprise can be a dull place, perhaps conversations can change that.
More general patterns:
A move away from tabbed navigation (in Web apps). This follows the “focus on content, not chrome” argument put forth by folks like Luke Wroblewski. Not sure about this one – well designed tabs can be great for complex forms.
More white space, padding (for reasons of touch, see above)
Bauhaus, minimalist design – Google redesign, Microsoft, Amazon redesign (header area); this “minimal” styling uses grays or desaturated colors, so that when a bright color is used, it’s used to draw attention.
Single page apps – lots of different “states” on a single page no longer feels like moving through linked “pages”
Very open layouts – less boxes and more lines/spacing to visually group areas; boxes still used on core content, but not as much for chrome/layout
Single column layouts – less distracting and mobile ready
More friendly, conversational language around form elements
Content being given proper information design treatment (varying type sizes, caps, shading, etc. to aid in understanding.
When dealing with almost every user-centric project in SharePoint there is some consideration of UX and not just the technical challenges we face. The interactions we design have a great impact on a projects success, and in turn a users satisfaction, and we almost always need to consider how broad the user base is going to be.
This means that employing patterns that are established and proven to be successful must surely help. With that said I think the web community create good trends based upon success so new styles are always evolving and we can help ourselves within the SharePoint platform by being more like the innovators on the wider web.
Whilst working on client project recently that involved InfoPath within Office365 I immediately wanted to use a commonly employed technique with previous projects – using the GetUserProfileByName web-service to obtain the users first and last name.
There are a number benefits to doing this, especially when the project inevitably involves workflow, custom library views, webparts etc to have a personalized experience for the user. For this specific project we needed to get the user of the form within the document as they were to form official standalone documents (as in out of the SharePoint document library context).
Unfortunately there is a BIG limitation…
“This issue occurs because loopback protection is enabled in the SharePoint Online environment. Loopback protection must be disabled for InfoPath forms to be able to connect to a SharePoint Online web service.
Any time that you make a call to the same server from an InfoPath form, the requests to loop back. This works only when loopback protection is disabled. For security reasons, loopback protection is always enabled in SharePoint Online. This is a known limitation of InfoPath forms in the Office 365 SharePoint Online environment, and there is no workaround for this issue.
Here is the article for your reference: http://support.microsoft.com/kb/2674193“
So we need another way to get the user data from within Office 365 and into the InfoPath form and I devised the following solution:
The overview is as follows
an InfoPath webpart
a query string filter connected to the InfoPath webpart
a javascript file to add the query string parameter
Now I had to provision a page with the Infopath webpart and a few other connected webparts
I then needed to get the InfoPath form to react to a query string filter webpart
I simplified his script to just read the current user via “get_title()” and then pass this to the “window. location”
This redirects to a url with a query string parameter “CurrentUser” with this value
…aspx?CurrentUser=Username
making sure to redirect only if the string “CurrentUser” is missing from the url. See the “check” statement…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
So I now had the current user in the url and the query string filter webpart reading the value and passing this to the InfoPath form field – I then had a people picker field read this value and bingo I could interact as if the original query was there.