Posts

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();...

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...

How to convert fields in lower case/upper case within Info path forms

Info path forms does not have any function to convert fields to lowercase or uppercase but there is an easy way to do it by using the translate function. Basically, the  translate  function returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding in the third argument. Using the translate function we can convert fields  from upper case to lower case, first word in upper case... or even use it to remove all the dashes and colons. The Translate function is better than the Replace function as can change several words at the same time. If we want every single character to get converted, we will have to specify every letter in the alphabet in upper case and then lower case to make sure every character will get converted. These are some examples: Converting from UPPER case to Lower case: translate( FieldToConvert , "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") C...

Saving a Sharepoint site as a template when the "Save as template" option is hidden

Saving a site or subsite as template allows you to save an existing site and use it as a template for new SharePoint sites or subsites with the same structure of your existing site, the site template can be saved with or without the content. Note that some customizations, such a custom workflows, will be present in your template only if you choose to include the content, but the size of your template will increase considerably. Take into account that saving site as template will not save the subsites under your site, if any, in the template. This option is usually available in the site settings page under “Site Actions” section, but this option will be hidden if the Publishing features  is turned on, as SharePoint does not support  Save Site as Template  option with this feature turned on. If the "Save site as template"option is not under Site Settings -> Site Actions, you just need to append _layouts/savetmpl.aspx to your subsites and you will be red...

Auto-populate the person/Group picker from the current user on InfoPath 2007/2010/2013

Image
If you need to fill the default value of the person/group picker with the current logged user when the form is loading, there is an easy way to do it. The following steps will show you how to do it: Create a web service connection to get the user profile information from the current user: Manage Data Connections -> Add -> Receive Data -> SOAP Web Service: Include the location of the SOAP Web service definition: http:// YourServer /_vti_bin/UserProfileService.asmx?WSDL Select GetUserProfileByName Make sure the "Automatically retrieve data when form is opened" option is ticked.   2. Add a Person/Group picker field to your info path form  3. Create a new action rule in the "Form Load" to run under a condition, if needed, i.e: Add the current user into the Person/Group picker field when the Person/Group picker field is blank:  DisplayName is blank 4. Set the Person/group picker DisplayName to Pref...