zondag 24 juni 2012

Value of approvalStatus changes in function of MUI Language


Believe it or not, but I was supprised that technical fields from Sharepoint are translated when
you change your MUI Language.

I discovered it by accident when a user called me, that my draft image was always visible
even when the document was approved. 
So after some debugging I saw that the approvalStatus field of sharepoint was translated in the
language of the MUI. 

In our configuration, we have English, Dutch and French. So the approvalStatus field is getting
in English the value "approved", in Dutch : "goedgekeurd" and in French : "approuvé" !

If you do equal stuff, I have coded next script in a Content Editor Webpart for my users : 
 

 //show draft image if topic is not approved
            if (document.getElementById('approvalStatus').innerHTML.toLowerCase() == 'approved' 
      || document.getElementById('approvalStatus').innerHTML.toLowerCase() == 'approuvé' 
      || document.getElementById('approvalStatus').innerHTML.toLowerCase() == 'goedgekeurd')
            {
                document.body.background = '';
            }
            else
   {
    document.body.style.backgroundPosition="center";
    document.body.style.backgroundImage="url(../../SiteCollectionImages/watermark-draft.png)";
    document.body.style.backgroundRepeat="no-repeat";
            }

 

Get User Roles, Security groups on Client site


Last week I figgered out how to know in which security group the logged-on user has access to 
in order to show or hide some fields or ribbon items. 
For example to prevent to show All Site Contents in the action menu.

Below some code that does the work for you... have fun with it ;)
 

<script src="/scripts/jquery-1.7.min.js" type="text/javascript"></script>
<script src="/scripts/jquery.SPServices-0.7.0.js" type="text/javascript"></script>
<script type="text/javascript">

 getCurrentUserRole();
 function getCurrentUserRole() {
  $().SPServices({
   operation: "GetGroupCollectionFromUser",
   userLoginName: $().SPServices.SPGetCurrentUser(),
   async: false,
   completefunc: function (xData, Status) {

    if( Status == "success") {
     //alert(xData.responseText);
     $(xData.responseXML).find("Group").each(function () {
      if ($(this).attr("Name") == "DevSite Owners")
      {
       alert("write access");
      }
      else
      {
       // wrong access hide some stuff... for example the Site Action link.
       $("#siteactiontd").hide();
       // hide the global navigation folder
       $("#GlobalBreadCrumbNavPopout-anchor").hide();
      }//alert($(this).attr("Name"));
     });
    }
   }
  });
 }
</script>
 

Refinements, "Show More" link stopped working

I recently discovered that the “Show More” link on the Search Refinement Panel web part 
had stopped working, seemingly out of the blue.  
With a bit of debugging I discovered that the functions defined in the onclick event:
onclick="SearchEnsureSOD();ToggleRefMoreLessFilters(this, true);"
were returning “Object Expected”.  
For some reason the functions were no longer defined.

I eventually figured out that the problem was that I had removed the Search Box web part 
from the page and replaced it with my own custom search box.  

Apparently the Search Box web part is required on the same page as the Refinement Panel web part,
as it injects JavaScript into the page that is used by the Refinement Panel.  

I fixed the problem by adding the Search Box web part back onto the page and hiding it.

 

donderdag 14 juni 2012

SharePointblog.co.uk is doing a 100 days/100posts on Business Analysis


Yust saw next big news in Balestra's Blog :

The people over at SharePointblog.co.uk are going to post 100 blogposts in the next 100 days 
about Business analysis to improve SharePoint requirements gathering. 

Some will be quick tips, other big posts.

They also have a twitter hashtag: #bamasterclass .

Don't miss it!!

Check if Sharepoint Richt Text Editor Field is empty or not


Today I had some problems to do a check wether a Rich Text Editor field is filled in or not. 
I found out that sharepoint also translates the Title of the Rich Text Editor field. 
That was really unexpected because the iframe is dynamically constructed in the browser. 
So you would expect that changing the MUI language would translate the 
Title propertie of the RTE field.
So for Frensh, Dutch and English MUI languages you could do the check like below.


var scomments = "";
if (_spPageContextInfo.currentLanguage == 1036) {
    var systemDescriptionRTE = $("textarea[Title='Comments']").closest("span").find("iframe[Title='Éditeur de texte enrichi']").contents().find("body");
    scomments = $(systemDescriptionRTE).text();
}
else
{
 if (_spPageContextInfo.currentLanguage == 1043) {
        var systemDescriptionRTE = $("textarea[Title='Comments']").closest("span").find("iframe[Title='RTF-editor']").contents().find("body");
        scomments = $(systemDescriptionRTE).text();
    }
    else
    {
        var systemDescriptionRTE = $("textarea[Title='Comments']").closest("span").find("iframe[Title='Rich Text Editor']").contents().find("body");
        scomments = $(systemDescriptionRTE).text();
    }
}

 
 
Bugfix available at this new blogpost :
 http://andydevelopments.blogspot.com/2012/10/check-if-sharepoint-richt-text-editor.html