SharePoint 2013: InfoPath client forms may open twice [Oct15CU bug]


December 16, 2015 - 20:47, by Steven Van de Craen - 2 Comments

Oops

After a recent Patch Night one of my customers had pulled in SharePoint updates along with Windows Updates and people started complaining about changed behavior

  1. PDF files no longer immediately open in the browser. Instead the PDF client (Adobe Reader) opens up and provides rich integration with options to check-out and such
  2. InfoPath client forms would open twice; meaning the form opens when clicking the link, but also an extra dialog appears to open the form. Users click this and receive messages about the form already being locked (by themselves!)

Hello little bug

We traced it to core.js (and core.debug.js) having a modified date of “15/09/2015 14:45” where functionality to provide “Acrobat Pro X integration” was introduced.

The function OpenDocWithClient is called in two different locations but the return value is ignored. This makes the page refresh that occurs when clicking the InfoPath form link execute more than desired.

Here’s the original (bugged) and modified (fixed by me) versions:

Original (bugged) core.js image

As you can see I added the “return” keyword for the function call, so the event cancelling can continue to bubble up.

For the minified version (core.js) you’ll have to do some digging but if you look for static strings you can find the function call. I think it was “m()” in my case.

Here ya go

You can download this archive which contains both my original and modified versions. If you modify your environment you have to update all web front ends and users will have to clear the browser cache, but no iisreset is required.

Note that later patches may overwrite the system files again and undo your manual changes.

End credits

This bug is introduced with the October 2015 updates, including the full Cumulative Update package. We escalated the case to Microsoft and they confirmed the issue and our workaround. It will probably remain present in the upcoming Cumulative Updates (November, December, …) because it’s not wide-spread and also the PG needs to fit it in into their schedule.


Delete All Items Ribbon Button


February 8, 2012 - 17:38, by Steven Van de Craen - 1 Comments

A SharePoint 2010 Sandboxed Solution that adds a Ribbon Button that recycles all items in a Document Library with a single mouse click.

I' have created this miniproject more as an academic exercise in creating a Ribbon Button than for real business value. It can come in handy for development environments sometimes.

Ribbon

Installation and activation

Download from here (Ventigrate Codeplex Repository)

Upload the WSP (sandbox solution) to the Site Collection Solution Gallery and activate it

Solution Gallery

Activate the Site Collection Feature

Site Collection Features

Final note

Some lessons learned and things worth noting:

  • Use a Module to deploy resource files to a folder or library like the Style Library (Sandbox cannot access the Layouts folder)
  • The Module will overwrite the existing resource files with a newer version, but will not delete them
  • Working with ECMAScript seems to have no effect on resource or resource quota
  • Use InPrivate Browsing for testing Ribbon development, this avoids caching of Ribbon resources
  • CustomAction.ScriptSrc points to the Layouts folder when using relative URLs. Use ~SiteCollection if you want to reference a resource in the Site Collection


SharePoint 2010 User Profile Page: Add as colleague–Link Fixup


December 27, 2011 - 10:43, by Steven Van de Craen - 2 Comments

Here’s a small fix for which I didn’t have time to investigate more properly:

Issue

The User Profile Page of another user shows a link “Add as colleague” when that user isn’t already a colleague:

User Profile Page

It seems however that the link behind “Add as colleague” directs to the Default AAM URL rather than the current URL you’re using.

Example:

Zone: Default http://internalserver
Zone: Intranet http://intranet

When browsing to the page using http://intranet the link will refer to http://internalserver. This is not the desired behaviour (think mixed authentication or extranet scenario’s).

Quick fix using jQuery

<script type="text/javascript" src="/my/Style Library/js/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(function() { var el = $('.ms-my-addcolleague'); if (el.attr('onclick') != undefined) { el.attr('onclick', el.attr('onclick').replace('http:\\u002f\\u002finternalserver:80', '')); } }); </script>

I’m referencing jQuery in the Style Library of the My Site Host, which you need to add or modify the link. I’ve hardcoded the internal URL (default zone public URL), might be better to look that up dynamically but as said this is a quick fix.

You can view the source of your own User Profile Page to find the internal URL for your environment.

You can add this in a Content Editor Web Part to the User Profile page and it should work just fine making the link relative.

Applies to

I’m seeing this issue in a SharePoint 2010 + Service Pack 1 + August 2011 Cumulative Update (14.0.6109.5002). Might be fixed in a later CU or SP.


Change language of the Spell Check in MOSS 2007


June 4, 2010 - 13:46, by Steven Van de Craen - 0 Comments

Want a quick way to change the language of the Spell Check for publishing pages in MOSS 2007 ? Place this script in your masterpage to set the language parameter before the call to the SpellCheck Web Service is made…

<script type="text/javascript">
  L_Language_Text = 100c;
</script>

Spell Check option in MOSS 2007

 

You’ll need to install a Language Pack for some languages: http://technet.microsoft.com/en-us/library/cc262108(office.12).aspx. To see the list of LCID’s you can go here: http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx

Good luck !


jQuery and screen manipulation flickering


November 9, 2009 - 14:43, by Steven Van de Craen - 0 Comments

We’re doing quite some jQuery improvements to our SharePoint developments such as inserting navigation for document libraries, reordering elements, hiding menu actions, etc. and one of the big issues is that the jQuery action occurs “on document ready” and the end user might see the manipulation happening if the javascript execution is just a bit delayed.

One of the solutions we’re using is to set the body hidden using CSS on load and then in our jQuery show it again as follows:

<style type="text/css">
body
{

display:none; }
</style>

<script type='text/javascript'>
$(
  function()
  {
    /* Your script) */

    /* Show rendered page */
    $('body').css('display', 'block');


  }
);
</script>

Works like a treat btw, but maybe any of you have a better way ?


Rooms and Equipment Reservations: Consistency Check Web Part


October 26, 2009 - 21:54, by Steven Van de Craen - 10 Comments

Still one of my most popular posts ever is the extension I wrote on the Rooms and Equipment Reservations template for SharePoint 2007 which allows you to manage reservations for meeting resources.

The idea behind RER is simple, but the architecture Microsoft chose (and unfortunately me too) is flawed. For each resource there are two types of reservation items; “Available” and “Reserved”. When making a reservation the “Available” item is shrunk, split or replaced with a “Reserved item”. The list of reservation items for a certain resource should thus be continuous based on their respective start and end times.

Since quite a few people from the community and also some customers are using the RERv2, I get a lot of feedback on these flaws, which I tend to ‘consistency issues’. These issues can’t really be traced back to bugs in code but seem to happen at random. For every 100 reservations are made I typically see 3 consistency issues. They don’t all have a great impact; some are not even noticed, others are blocking future reservations for that resource.

Ideally the mechanism would have to be rewritten to just use “Reserved” items. This would make the fault ratio significantly smaller. However that project has been put in the fridge until further notice I’m afraid.

There is a sparkle of light at the end of the tunnel however ! I am releasing a Web Part that allows you to quickly correct consistency issues. And it’s even free ! ;)

Downloadables

Installation Instructions

1) WSP

The installation package (above) contains a SharePoint Solution (.wsp) to deploy using STSADM:

STSADM -o addsolution -filename RER.v2.ConsistencyCheckWebPart.wsp
STSADM -o deploysolution -name RER.v2.ConsistencyCheckWebPart.wsp -immediate -allowgacdeployment

2) Web Parts

Next in SharePoint create a Document Library (e.g. Pages) in the RER site where you upload the jQuery.js and RERAdmin.txt files from the install package. These make up the formatting and collapsing behaviour of the resources and reservations.

Also create a Web Part Page in this library called RERAdmin.aspx .

Add the ConsistencyCheckWebPart and RERAdmin_CSS_and_JS Web Parts on the RERAdmin page. You can import these Web Part directly if you go through Add Web Part > Advanced Web Part gallery and options > Import

It is best to break permissions and tighten security on the Web Part page so that users don’t inadvertently access the Consistency Check Web Part !

Usage Instructions

The Web Part must be placed in a site based on RERv2. It will automatically load the list of resources and corresponding reservations. If the CSS and JavaScript are in place the reservations are collapsed by default and the items will either have a green (good) or red (bad) icon. If it’s red that means there are consistency issues in the stream of reservation items for that resource.

The editor on the bottom of the Web Part will allow you to make changes directly to reservations.

 

NOTE: The number between square brackets is the item ID of either the resource or reservation item. You will need this to Modify or Delete a reservation !

Possible causes:

ISSUE EXPLANATION FIX
There are no reservations The workflow on the Resource hasn’t run (yet). Add an “Available” reservation for the resource with no specified end time, or recreate the resource to trigger the workflow.
There are two adjacent “Available” reservations They should be merged into a single “Available” item. Delete one of the items and Modify the remaining item to become ‘continuous’.
There are overlapping reservations A resource was booked twice. Normally this is prohibited but could occur in some rare conditions. Remove on of the items or Modify the start and/or end times to resolve this.
Reservations are not continuous All items should form a ‘continuous stream’ based on their start and end times. Modify the timings so that they become ‘continuous’.


Ellipsis on list item body using jQuery


October 1, 2009 - 22:35, by Steven Van de Craen - 0 Comments

A common question to receive is on list items with a long body (eg. Announcements) and then show only X characters and optionally a ‘read more’ link. Many ways to solve this but I went for the following: a Custom Field Type that renders the short text with ellipsis using jQuery.

This is another example using the Advanced Computed Field in a creative way. The ACF allows you to create computed fields referencing other fields or data in your list and manipulating them through CAML or JavaScript. It has the advantage that this can be done from within the browser, however I admit CAML isn’t the easiest of things to comprehend in the SharePoint technology stack.

Ellipsis sample

This ellipsis displays the first 20 characters of the plain text version of the Announcement Body

<FieldRefs> 
     <FieldRef Name="Body" />
     <FieldRef Name="ID" />
</FieldRefs>

<DisplayPattern>
     <HTML>&lt;span style="display:none;" id="el_</HTML>
     <GetVar Name="WPQ" />
     <HTML>_</HTML>
     <Field Name="ID" />
     <HTML>"&gt;</HTML>
     <Field Name="Body" />
     <HTML>&lt;/span&gt;</HTML>
     <HTML>
     &lt;script type="text/javascript"&gt;
     $(function()
     { var mySpan = $('#el_</HTML>
     <GetVar Name="WPQ" />
     <HTML>_</HTML>
     <Field Name="ID" />
     <HTML>');
       var myShortText = $(mySpan).text().substring(0, 20); 
       if ($(mySpan).text().length &gt; 20)
         myShortText += '...';

       $(mySpan).show().html(myShortText); });
     &lt;/script&gt;</HTML>
</DisplayPattern>

Notes
  • If you prefer to not escape the brackets you can use CDATA tags: <HTML><![CDATA[<b>hello</b>]]></HTML>
  • GetVar ‘WPQ’ returns the unique Web Part ID. This takes care of multiple List View Web Parts on the same page
  • You could optimize the output by extracting most of the script and placing it in an externally referenced JavaScript file
  • My JavaScript/jQuery skills aren’t the best. I’ll have to ask Jan for some jQuery pointers next time :)