Posts

How to show specific views depending on the current user group in a SharePoint list

There is a way to show and redirect users to specific views depending on their group, by modifying the "AllItems.aspx" page. Firstly, create  library within your site called JqueryLibraries and put there the  jquery-1.9.0.js and the  jquery.SPServices-0.7.2.js libraries. You can download the  jquery.SPServices-0.7.2.js  from here: http://spservices.codeplex.com/releases/view/81401  (unzip the file and use the .js version) You can download the  jquery-1.9.0.js  from here: http://code.google.com/p/google-caja/source/browse/trunk/third_party/precajole/jquery/1.9.0/?r=5248 Create the views where you want the user to be redirected (i.e: Your1View.aspx and Your2View.aspx). Make a security copy of the "AllItems.aspx" page, delete everything in the original page and paste the following: <%@ Page Language="C#" %> <html dir="ltr"> <script language="javascript" src="/ SiteName / JqueryLibraries /jquery-1.9.0.js

How to add language localization to your info path web browser form 2010/2013

Image
Sometimes your form needs to be available in different languages. This solution provides you with an "easy" way to change the language of  drop down lists, buttons, labels and screen-tips depending on the selected language through a XML file and some rules. The following example shows how to to do all of this in 3 languages (English, Spanish and Basque) : The following steps will show you how to set up the drop down list that will change between the languages: C reate a XML file using the following format: <?xml version="1.0" encoding="UTF-8"?> <LocalSettings>     <Languages>         <Language Name="English" Code="ENG"/>         <Language Name="Español" Code="SPA"/>         <Language Name="Euskara" Code="EUS"/>         </Languages>     <Labels>           <Label Name="Personal Data">             <LocalL

Getting the group Name of the current user in Info path forms

Image
Sometimes, it is useful to get the group name of the current user in order to create rules based on that group, i.e: if we want to manage the permissions within the form through views depending on groups. The following example shows how to get the group name of the current user .  I have divided the steps in 4 main sections: Creating a web service connection :  New web service connection need to be created to obtain the group name thought the  GetGroupCollectionFormUser  service. Exporting the form:   The form needs to be exported as we will apply some changes in one of the exported files. Updating the XSD file : Edit the GetGroupCollectionFormUser1.xsd file. Creating rules to manage the permissions within the form : The form permissions will be managed through rules created in the Form Load. Users will see different form views depending on the groups they belong to. Creating a web service connection: Manage Data Connections -> Add -> Receive Data -> SOAP

How to access repeating table/section fields in Info Path Web Browser Forms

Accessing or validating fields within a repeating table/section using web  browser forms might be a little bit tricky, as web browser forms will not allow you to reference specific rows by index, use Last() or Position() functions... There are some XPath formulas that you can use to access or validate fields within a repeating section with out having to use any extra code in your form. These are some examples: Check if a repeating section/table has duplicate rows: count( XpathToRepeatingGroup [following-sibling::*/ FieldToBevalidated = FieldToBeValidated ]) > 0 If value returned by the XPath expression is greater than 0 then the repeating table contains duplicate rows. The number returned by the XPath expression will be the number of duplicate rows that your repeating section contains. Do not forget to include in the condition when field is not blank, as blank values count as duplicates. Get the previous row value: ../ preceding-sibling:: my:RepeatingGroup [count(precedin

How to fix Web Part problems

If a web part or web part connection is corrupted or did not install properly might be a little bit tricky to remove or update the web part as you usually do. Sometimes, you will receive "Unexpected error has occurred" message, or a "#" symbol will be added at the end of your aspx page URL avoiding you to remove or update the corrupted web part in the "normal" way. There is an easy way to fix the corrupted web part by adding "?Contents=1" at the end of the Address Bar as showing in the following example: http://SiteName/Page.aspx ? Contents=1 The Page.aspx is the aspx page where your web part is placed on. The SiteName is the name of the site where the page that contains your web part is. Once you include  the "?Contents=1" at the end of your Address Bar, y ou will be redirected to the Web Part Maintenance page (You must have the appropriate permissions to use the Web part Maintenance Page). Now, make sure that you are in

Differences between "Throw","Throw ex" and "Throw new Exception(...)" in .NET

The T hrow statement is used to inform about the occurrence of an exception when a program is executing. Exceptions contain a property named StackTrace . This string contains the name of the methods on the current call stack, apart from the file name and line number from where the exception was thrown for each method. There are 3 different ways to use the Throw statement: Throw Ex:   The original stack trace will be overwritten with a new stack trace that starts from the throwing method. Throw:   Preserves the original stack trace information because rethrows the original exception. Throw new Exception(...): Keeps original stack trace and adds aditional details.        Example: class Maths {     static void Main(string[] args)     {         try         {             MethodX();         }         catch (Exception ex)         {             // Throw Ex  - Method X stack trace (Method Y has been overridden)             //Exception: System.DivideByZeroException: Attem

How to auto save a browser enabled info path form every X minutes in Sharepoint 2007, 2010 and 2013

Info Path forms can be saved automatically every X minutes by updating the FormServer.aspx file. This update will avoid for users to lose their information when the session has expired and they forgot to save the form. The following code add some conditions so only the forms within a specific site and form view will be saved . I recommend you to copy the FormServer.aspx file before start with the changes to facilitate the file recovery if it fails. Update the FormServer.aspx file using a text editor as following:   If you are using SharePoint 2007: Include before the   </head>  tag    the following: < script language ="javascript" type ="text/javascript" > var timer_is_on = 0; var t; function doTimer() { clearTimeout(t); if (document.URL.indexOf( "SiteName" ) != -1) if (g_objCurrentFormData[9] != "FormViewToExclude"  && PostbackBody.intPostbacksInProgress == 0) if (!timer_is_on) { timer_is_on